スクリーンショットでは、多くのことが明らかになります。基本的には、私はこのサービスを持っており、WCFテストクライアントを使用して、文字列を返すことができます。しかし、Visual Studioを使用して作成したClient Sideリファレンスには、私のメソッドがvoidとして返されることが記載されています。WCF .svcファイルに戻り値の型があります。クライアントコードはすべて無効です。
Test()メソッドのServerConnectionオブジェクトは、Visual Studioによって作成されたサービスリファレンス変数を参照しています。
Root.svc.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace chatService_SignalRService.Services
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Root" in code, svc and config file together.
// NOTE: In order to launch WCF Test Client for testing this service, please select Root.svc or Root.svc.cs at the Solution Explorer and start debugging.
public class Root : IRoot
{
public String DoWork()
{
return "Hello Bailey!";
}
}
}
IRoot.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace chatService_SignalRService.Services
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IRoot" in both code and config file together.
[ServiceContract]
public interface IRoot
{
[OperationContract]
String DoWork();
}
}
私は汎用性のあるクラスライブラリを使用しています。そのクラスライブラリを選択し、サービス参照を追加し、アドレスをWebサーバーにポイントし、ServerCTという名前を付けます。
ポータブルクラスライブラリの下にある私のProfile.csでは、オブジェクトとメソッドを作成します。
using Microsoft.AspNet.SignalR.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Classes
{
public class Profile : User
{
public static ServerCT.RootClient ServerConnection = new ServerCT.RootClient();
public void Test()
{
ServerConnection.DoWorkAsync();
}
}
}
スクリーンショット:彼らは非同期であり、何の結果を返さないので、
スクリーンショットを掲示する代わりに完全なコードをここに掲載してください。あなたに答えを与えるためにスクリーンショットからあなたのコードを再入力したい人はいません。 –
私はコードを投稿します、多分いくつかの異なるファイルに5行のコードがあります。 –