【发布时间】:2017-12-17 11:37:17
【问题描述】:
在我的 WCF 服务 App.config 我有:
<services>
<service behaviorConfiguration="MyServiceWcfBehavior" name="MyService">
<clear />
<endpoint address="net.tcp://localhost:9999/MyService" binding="customBinding" bindingConfiguration="MyServiceTcpBinding" name="MyServiceWcfTcpEndpoint" contract="MyService.Contracts.Interfaces.IMy" />
</service>
</services>
在我的测试客户端 App.config 我有:
<client>
<endpoint address="net.tcp://localhost:9999/MyService" behaviorConfiguration="MyServiceEndpointBehavior" binding="customBinding" bindingConfiguration="MyServiceCustomTcpBinding" contract="MyService.Contracts.Interfaces.IMy" name="MyServiceWcfTcpEndpoint" />
</client>
然后我像这样实例化我的ServiceHost:
var host = new ServiceHost(typeof(MyService),new Uri(net.tcp://localhost:9999/MyService));
host.Open();
但是在运行我的服务然后用我的客户端进行测试(调用我的服务中定义的通道端点)我得到运行时异常:
System.ServiceModel.FaultException`1 未处理 行动=http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault H结果=-2146233087 Message=该方法或操作未实现。 源=mscorlib 堆栈跟踪: 服务器堆栈跟踪: 在 System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(消息 回复、MessageFault 故障、字符串操作、MessageVersion 版本、 故障转换器故障转换器) 在 System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime 操作,ProxyRpc&rpc) 在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] 出局,TimeSpan 超时) 在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall、ProxyOperationRuntime 操作) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 信息) 在 [0] 处重新抛出异常: 在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(消息数据& msgData,Int32 类型)
【问题讨论】:
-
您尝试通过测试客户端调用的方法是否已在服务中实现?
标签: c# .net wcf service wcfserviceclient