WCF回调生成接口
.NET Framework 3.5。在服务器端,我有一个接口WCF回调生成接口,wcf,wcf-client,Wcf,Wcf Client,.NET Framework 3.5。在服务器端,我有一个接口 public interface IClientCallback { [OperationContract(IsOneWay = true)] void ReceiveBroadcast(string nickname, string message); [OperationContract(IsOneWay = true)] void ReceivePrivate(string nickname,
public interface IClientCallback
{
[OperationContract(IsOneWay = true)]
void ReceiveBroadcast(string nickname, string message);
[OperationContract(IsOneWay = true)]
void ReceivePrivate(string nickname, string message);
[OperationContract(IsOneWay = true)]
void UserJoined(string nickname);
[OperationContract(IsOneWay = true)]
void UserLeft(string nickname);
}
使用svcutil,我生成了folliwing接口
public interface IServerCallback
{
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://tempuri.org/IServer/ReceiveBroadcast")]
void ReceiveBroadcast(string nickname, string message);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, AsyncPattern=true, Action="http://tempuri.org/IServer/ReceiveBroadcast")]
System.IAsyncResult BeginReceiveBroadcast(string nickname, string message, System.AsyncCallback callback, object asyncState);
void EndReceiveBroadcast(System.IAsyncResult result);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://tempuri.org/IServer/ReceivePrivate")]
void ReceivePrivate(string nickname, string message);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, AsyncPattern=true, Action="http://tempuri.org/IServer/ReceivePrivate")]
System.IAsyncResult BeginReceivePrivate(string nickname, string message, System.AsyncCallback callback, object asyncState);
void EndReceivePrivate(System.IAsyncResult result);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://tempuri.org/IServer/UserJoined")]
void UserJoined(string nickname);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, AsyncPattern=true, Action="http://tempuri.org/IServer/UserJoined")]
System.IAsyncResult BeginUserJoined(string nickname, System.AsyncCallback callback, object asyncState);
void EndUserJoined(System.IAsyncResult result);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://tempuri.org/IServer/UserLeft")]
void UserLeft(string nickname);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, AsyncPattern=true, Action="http://tempuri.org/IServer/UserLeft")]
System.IAsyncResult BeginUserLeft(string nickname, System.AsyncCallback callback, object asyncState);
void EndUserLeft(System.IAsyncResult result);
}
正如您所见,它提供了End*和Begin*方法,尽管所有操作都是单向的。原因可能是什么?我尝试将AsyncPattern=false添加到IClientCallback方法中,但没有结果。是否设置了svcutil以生成异步操作?不,我没有。我只需运行svcutil Server.exe并生成.cs文件。此外,我还尝试将AsyncPattern=false添加到IClientCallback方法中,但没有结果。Mackho,你救了我的命!!!:)我删除了/a,它成功了。