C# The provided URI scheme 'http' is invalid; expected 'https'
Asked Answered
B

5

16

I am getting this error while invoking a method of my web service, I dont know what to do anymore :s

Here is the exception details:

{"The provided URI scheme 'http' is invalid; expected 'https'.\r\nParameter name: via"}

Here is my App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

    <connectionStrings>
      <add name="PowerWeb" connectionString="Data Source=MYSERVER;Initial Catalog=MYTABLE;User ID=MYUSER;Password=MYPW" providerName="System.Data.SqlClient" />
    </connectionStrings>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>



      <bindings>
        <customBinding>
          <binding name="ZWS_HARMONIZACAO">
            <!--    WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'urn:sap-com:document:sap:rfc:functions':    -->
            <!--    <wsdl:binding name='ZWS_HARMONIZACAO'>    -->
            <!--        <saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/">..</saptrnbnd:OptimizedXMLTransfer>    -->
            <!--        <saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/">..</saptrnbnd:OptimizedXMLTransfer>    -->
            <!--        <sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">..</sapattahnd:Enabled>    -->
            <textMessageEncoding messageVersion="Soap11" />

            <httpsTransport authenticationScheme="Basic"  />


          </binding>
        </customBinding>
      </bindings>
        <client>
            <endpoint address="http://mydomain:8080/sap/bc/srt/rfc/sap/zws_harmonizacao/010/zws_harmonizacao/zws_harmonizacao"
                binding="customBinding" bindingConfiguration="ZWS_HARMONIZACAO"
                contract="ServiceReference1.ZWS_HARMONIZACAO" name="ZWS_HARMONIZACAO" />
        </client>

    </system.serviceModel>
</configuration>

Can anyone help me? Thanks a lot in advance

Burk answered 14/2, 2014 at 12:22 Comment(4)
Did you try changing address="http://mydomain:8080/sap/bc/srt/rfc/sap/zws_harmonizacao/010/zws_harmonizacao/zws_harmonizacao" to address="https://mydomain:8080/sap/bc/srt/rfc/sap/zws_harmonizacao/010/zws_harmonizacao/zws_harmonizacao"? (add an s to http)Glutton
That gives me another error: Binding Failure - The name '$exception' does not exist in the current contextBurk
What is your code that uses this? The name exception is not defined in the code snippet above.Glutton
Its while invoking a method from a web service.. here is the snippet code tny.cz/6e0740b3Burk
K
8

You are specifying an httpsTransport in the binding, but in the endpoint definition you are providing http as a protocol. As suggested in the comment, try changing the <endpoint address="http://... to https

Keyser answered 14/2, 2014 at 12:29 Comment(1)
Thanks for your answer but is giving me another error: BindingFailure: The name '$exception' does not exist in the current context. I tried to change httpsTransport to httpTransport and the error was the same..Burk
G
7

Change from Transport to None

  1. If configuration is part of Code

BasicHttpSecurityMode.Transport to BasicHttpSecurityMode.None

2.If configuration is part of web.config

<security mode="Transport"> </security>

to

<security mode="None">  
</security>
Gelhar answered 15/2, 2019 at 9:53 Comment(0)
U
5

I have changed the configuration of the binding like this:

 var binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
 var address = new EndpointAddress(url);
 var client = new MobileServiceClient.MobileServiceClient(binding, address);

The endpoint address is like:

http://server101.local/MobileService.svc

And it works.

Uziel answered 12/9, 2016 at 13:23 Comment(0)
K
2

I had the same problem y one project. Simply in your config file change the line:

<httpsTransport authenticationScheme="Basic"  />

to

<httpTransport authenticationScheme="Basic"  />

And all ok, because your endpoint is http.

Kite answered 22/7, 2015 at 7:59 Comment(0)
G
-3

[Solved] Change from Transport to None If configuration is part of code

BasicHttpSecurityMode.Transport to BasicHttpSecurityMode.None

Gelhar answered 15/2, 2019 at 9:31 Comment(1)
Since you have posted another answer more complete, please delete this one.Archil

© 2022 - 2024 — McMap. All rights reserved.