我们有wcf服务,该服务在净tcp绑定上运行并具有回叫合同。 当我尝试使用双工代理通道调用服务方法时,出现以下错误。服务正在运行,但无法与代理客户端连接。
C#
this.Invoke(p => p.Subscribe(), true);
public void Invoke(Action<T> call, bool keepOpen)
{
T proxy = GetProxy();
call(proxy);
}
public T GetProxy()
{
NetTcpBinding binding = new NetTcpBinding("");
EndpointAddress address = new EndpointAddress(new Uri("net.tcp://" + Server + RelativeUrl), EndpointIdentity.CreateSpnIdentity(Server + "/" + Environment.MachineName));
factory = new DuplexChannelFactory<T>(new InstanceContext(callbackInstance), binding, address);
T proxy = factory.CreateChannel();
((IClientChannel)proxy).Open();
return proxy;
}
[ServiceContract(SessionMode = SessionMode.Required, CallbackContract = typeof(IWorkflowChanged))]
public interface IWorkflowChangedPublisher
{
[OperationContract(IsOneWay = false)]
void Subscribe();
}
public interface IWorkflowChanged
{
[OperationContract(IsOneWay = true)]
void WorkflowChanged(WorkflowChangedEventArgs args);
}
得到以下异常:
Server stack trace:
at System.ServiceModel.Dispatcher.DuplexChannelBinder.SyncDuplexRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Tradar.Workflow.Service.IStatusPublisher.Subscribe()
at Tradar.Workflow.StatusMonitor.<>c.<Open>b__16_0(IStatusPublisher p) in D:\PMARepo\backoffice\Insight\Modules\Workflow\Core\StatusMonitor.cs:line 139
at Tradar.Workflow.ProxyFactory`1.Invoke(Action`1 call, Boolean keepOpen) in D:\PMARepo\backoffice\Insight\Modules\Workflow\Core\ProxyFactory.cs:line 79