我的服务配置如下:
<system.serviceModel> <services> <service name="WcfService1.Service1" behaviorConfiguration="MyServiceTypeBehaviors"> <host> <baseAddresses> <add baseAddress="net.tcp://127.0.0.1:808/service" /> </baseAddresses> </host> <endpoint address="net.tcp://127.0.0.1:808/service/" binding="netTcpBinding" contract="WcfService1.IService1"/> <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /> </service> </services> <protocolMapping> <add scheme="net.tcp" binding="netTcpBinding"/> </protocolMapping> <behaviors> <serviceBehaviors> <behavior name="MyServiceTypeBehaviors"> <serviceMetadata httpGetEnabled="true"/> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="MyEndpointBehaviour"> <webHttp/> </behavior> </endpointBehaviors> </behaviors> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> </system.serviceModel>和客户端:
<system.serviceModel> <bindings> <netTcpBinding> <binding name="NetTcpBinding_IService1" sendTimeout="00:05:00" /> </netTcpBinding> </bindings> <client> <endpoint address="net.tcp://127.0.0.1/service/" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IService1" contract="IService1" name="NetTcpBinding_IService1"> <identity> <servicePrincipalName value="host/MachineName" /> </identity> </endpoint> </client> </system.serviceModel>使用 WCFTestClient 或 SVCutil 时,我能够发现和访问服务并生成代理或存根.
When using WCFTestClient or SVCutil, I am able to discover and access the servie and generate proxy or stubs.
但是当我想调用任何出现以下错误的方法时:
But when I want to invoke any of the methods getting following error:
未能调用该服务.可能的原因:服务离线或无法访问;客户端配置与代理不匹配;现有代理无效.有关更多详细信息,请参阅堆栈跟踪.您可以尝试通过启动新代理、恢复默认配置或刷新服务来恢复.
Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.
套接字连接被中止.这可能是由于处理您的消息时出错或远程主机超过接收超时,或底层网络资源问题所致.本地套接字超时为00:04:59.9980468".
The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:04:59.9980468'.
推荐答案在端点块内设置以下值
<identity> <dns value ="localhost"/> </identity>更多推荐
调用服务失败.可能原因:调用时服务离线或无法访问
发布评论