1

我在使用 web 服务时遇到问题,当我尝试访问某些方法时出现此错误:

mscorlib.dll 中出现“System.ServiceModel.CommunicationException”类型的异常,但未在用户代码中处理

附加信息:向https://flightxml.flightaware.com/soap/FlightXML2/op发出 HTTP 请求时出错。这可能是由于在 HTTPS 情况下未使用 HTTP.SYS 正确配置服务器证书。这也可能是由于客户端和服务器之间的安全绑定不匹配造成的。

我这样调用网络方法

FlightXML2SoapClient client = new FlightXML2SoapClient();
        
client.ClientCredentials.UserName.UserName = username;
client.ClientCredentials.UserName.Password = password;
        
string[] pm = client.AllAirports();
        
   

我也尝试过 securityprotol(ssl3,tls11,tls12) 但仍然没有。我什至尝试了不同版本的框架(5.0、6.0 和 7.0),但我得到了同样的错误。

我的 webconfig 看起来像这样

  </system.codedom>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="FlightXML2Soap">
          <security mode="Transport">
            <transport clientCredentialType="Basic"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://flightxml.flightaware.com/soap/FlightXML2/op" binding="basicHttpBinding" bindingConfiguration="FlightXML2Soap" contract="FlightAwareXML.FlightXML2Soap" name="FlightXML2Soap"/>
    </client>
  </system.serviceModel>
4

0 回答 0