Friday, 21 December 2012

The provided URI scheme 'https' is invalid; expected 'http'

A really annoying error which is hard to understand until it is explained and then it makes perfect sense!
I was getting this on Azure when calling from a web application to a web service.
What it means is that the client endpoint you have specified (the "provided URI") has a scheme of https at the begining (the client url is https://whatever) whereas the meta-data for the endpoint that you probably added with "Add Service Reference" discovered that the protocol was http on the service binding. I got this with a client config in the web app of:

<endpoint address="https://6ead981357238479hfc0beff3193e7b.cloudapp.net/WebService.svc/standard"
    binding="wsHttpBinding" bindingConfiguration="standard" contract="IWebService"
    name="standard">
    <identity>
      <servicePrincipalName value="host/RD00443D49795E" />
    </identity>
  </endpoint>

And a service configuration of:

<binding name="standardConfig" maxReceivedMessageSize="65536000">
  <readerQuotas maxDepth="32"
                maxStringContentLength="65536000"
                maxArrayLength="65536000"
                maxBytesPerRead="65536000"
                maxNameTableCharCount="65536000" />
</binding>

The fix is either to specify http on the client endpoint in the web application or to add <security mode="transport"> to the binding on the web service:

<binding name="standardConfig" maxReceivedMessageSize="65536000">
  <security mode="Transport"></security>
  <readerQuotas maxDepth="32"
                maxStringContentLength="65536000"
                maxArrayLength="65536000"
                maxBytesPerRead="65536000"
                maxNameTableCharCount="65536000" />
</binding>

If you do modify the service binding, you will need to update the service reference on the web app to ensure it now knows that the expected scheme is https.

No comments: