【问题标题】:'https' is invalid; expected 'http''https' 无效;预期的“http”
【发布时间】:2013-12-19 03:36:33
【问题描述】:

我一直在尝试向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;

【问题讨论】:

  • 更改您的端点以使用http,就像异常告诉您的那样。
  • @Tehreem 请检查更新的答案。

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


【解决方案1】:
<security mode="Transport"> in Servicereference.ClientConfig file

Here

Check here too

更新:根据您的 cmets :

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

【讨论】:

  • 你的意思是Web.Config吗?我有 Web.Config 但在任何地方都没有 Servicereference.ClientConfig。我通过给我的 wsdl 文件引用了这些服务。 VS生成了reference.cs文件但是没有config..?
猜你喜欢
  • 2010-12-14
  • 1970-01-01
  • 2012-04-09
  • 2012-12-31
  • 1970-01-01
  • 2015-11-19
  • 1970-01-01
  • 2011-01-27
  • 1970-01-01
相关资源
最近更新 更多