无法解析 SOAP 服务的主机名

Unable to Resolve Host Name of SOAP Service

我添加了对我无法控制的第三方 API 的服务引用。

端点看起来像这样(URL 掩码)并且可以从这个地址获得服务,因为我可以使用 SOAPUI 调用它:

<endpoint address="https://some-api.domain.com/service-name/do-something"
    binding="basicHttpBinding" bindingConfiguration="FindPolicyPortSoap11"
    contract="FindPolicy.FindPolicyPort" name="FindPolicyPortSoap11" />

调用该服务时,我收到错误 The remote name could not be resolved: 'some-api.domain.com,这在技术上是正确的,因为 some-api.domain.com 会产生 404,而 some-api.domain.com/service-name/do-something 按预期工作。

我该怎么做才能让它正常工作?

此错误与将某些-api.domain.com 解析为特定 IP 地址有关 我会尝试使用 nslookup 或 http://www.kloth.net/services/nslookup.php 另一种选择是将此域添加到您的主机文件中只是为了测试它

您是否尝试过在 system.net 标签中将 defaultproxy 设置为 true?

根据 MSDN

If the defaultProxy element is empty, the proxy settings from Internet Explorer will be used. This behavior is different from version 1.1 of the .NET Framework.

<defaultProxy  
        enabled="true|false"  
        useDefaultCredentials="true|false">  
           <bypasslist> … </bypasslist>  
           <proxy> … </proxy>  
           <module> … </module>  
      </defaultProxy>

https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/network/defaultproxy-element-network-settings