调用服务失败.可能原因:调用时服务离线或无法访问 [英] Failed to invoke the service. Possible causes: The service is offline or inaccessible while Invoking

查看:207
本文介绍了调用服务失败.可能原因:调用时服务离线或无法访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的服务配置如下:

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

这篇关于调用服务失败.可能原因:调用时服务离线或无法访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆