我正在尝试连接到我们的 Intranet 中托管的服务。但是,这样做时我收到了这个错误:
System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at http://10.XXX.X.XXX:XXXX/servicename/services/SomeSearch.SomeSearchHttpSoap12Endpoint/ that could accept the message. This is often caused by an incorrect address or SOAP action.
内部异常说:
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond http://10.XXX.X.XXX:XXXX
这是我的配置文件:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="SomeSearchSoap11Binding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
<customBinding>
<binding name="SomeSearchSoap12Binding" receiveTimeout="01:10:00">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap12" writeEncoding="utf-8" >
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
</textMessageEncoding>
<httpTransport manualAddressing="false" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true"/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://10.XXX.X.XXX:XXXX/servicename/services/SomeSearch.SomeSearchHttpSoap11Endpoint/" binding="basicHttpBinding" bindingConfiguration="SomeSearchSoap11Binding" contract="SomeService.SomeSearchPortType" name="SomeSearchHttpSoap11Endpoint"/>
<endpoint address="http://10.XXX.X.XXX:XXXX/servicename/services/SomeSearch.SomeSearchHttpSoap12Endpoint/" binding="customBinding" bindingConfiguration="SomeSearchSoap12Binding" contract="SomeService.SomeSearchPortType" name="SomeSearchHttpSoap12Endpoint"/>
</client>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
这些是我遵循的步骤:
我通过提供 wsdl 路径添加了服务引用。
实例化 SomeSearchPortTypeClient
在客户端调用方法如下:
var someService= new SomeSearchPortTypeClient("SomeSearchHttpSoap12Endpoint"); var 文档 = someService.getSomething("123");
当我这样做时,我得到了上述异常。
我还尝试了 ping 到 10.XXX.XXX.XXXX,但超时。这可能是防火墙问题吗?如果是,我的下一步应该是什么?我应该追求哪些其他角度来实现这个工作?
需要注意的一点是,代理客户端是在没有任何异常的情况下实例化的,只有在进行服务调用时它才会让我返回这个错误。