调用服务失败.可能原因:调用时服务离线或无法访问

编程入门 行业动态 更新时间:2024-10-20 20:41:48
本文介绍了调用服务失败.可能原因:调用时服务离线或无法访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的服务配置如下:

<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>

更多推荐

调用服务失败.可能原因:调用时服务离线或无法访问

本文发布于:2023-10-24 14:04:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524130.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:离线   无法访问   原因

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!