'https'无效;预期'http'

时间:2013-12-03 07:14:45

标签: c# asp.net web-services basic-authentication

我一直在尝试向https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/SystemService发送ping请求,但我收到以下错误: Error making ping request: The provided URI scheme 'https' is invalid; expected 'http'.

提供给我的终点使用https。如何更正此错误?

这是我的web.config

<?xml version="1.0"?>
 <configuration>
<system.web>
  <compilation debug="true" targetFramework="4.5" />
  <httpRuntime targetFramework="4.5" />
</system.web>

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="ExternalCacheAccessBinding" />
            <binding name="SystemPingBinding" />
            <binding name="SystemInfoBinding" />
            <binding name="SystemTimeBinding" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/SystemService"
            binding="basicHttpBinding" bindingConfiguration="ExternalCacheAccessBinding"
            contract="WSDLService.ExternalCacheAccessPortType" name="ExternalCacheAccessPort" />
        <endpoint address="https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/SystemService"
            binding="basicHttpBinding" bindingConfiguration="SystemPingBinding"
            contract="WSDLService.SystemPingPortType" name="SystemPingPort" />
        <endpoint address="https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/SystemService"
            binding="basicHttpBinding" bindingConfiguration="SystemInfoBinding"
            contract="WSDLService.SystemInfoPortType" name="SystemInfoPort" />
        <endpoint address="https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/SystemService"
            binding="basicHttpBinding" bindingConfiguration="SystemTimeBinding"
            contract="WSDLService.SystemTimePortType" name="SystemtimePort" />
    </client>
</system.serviceModel>

这是我在教程后发送的请求:

// PING REQUEST
    //

    String payload= "this my payload; there are many like it but this one is mine";
    String someTraceId = "doesntmatter-8176";

    //set up the request parameters into a PingReq object
    PingReq req = new PingReq();
    PingRsp rsp = new PingRsp();
    req.Payload=payload;
    req.TraceId=someTraceId;
    SystemPingPortTypeClient port = new SystemPingPortTypeClient();
    try {
        //run the ping request
        UserNamePasswordClientCredential creds = port.ClientCredentials.UserName;
        creds.UserName = "MyUserName";
        creds.Password = "MyPassword";

        rsp = port.service(req);
        //print results.. payload and trace ID are echoed back in response
        Label1.Text = rsp.Payload;
        Label2.Text = rsp.TraceId;
        Label3.Text = rsp.TransactionId;
        } 
    catch (Exception ex) {
    //usually only the error message is useful, not the full stack
    //trace, since the stack trace in is your address space...
    Label1.Text = "Error making ping request: " + ex.Message;

1 个答案:

答案 0 :(得分:4)

<security mode="Transport"> in Servicereference.ClientConfig file

Here

Check here too

更新:根据您的意见:

 <bindings>
   <basicHttpBinding>
   <security mode="Transport">