the provided uri scheme https is invalid; expected 'http' in app.config - wcf

I have a wcf with like below url
https://localhost:44370/service.svc
I have a window service which is using the above wcf
and in my app.config I configured the same like below
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpsBinding_IService" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost:44370/service.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpsBinding_IService" contract="FileServer.IService"
name="BasicHttpsBinding_IService" />
</client>
</system.serviceModel>
but I am getting the following error the provided uri scheme https is invalid; expected 'http'
when I changed my binding type into https like below
<system.serviceModel>
<bindings>
<basicHttpsBinding>
<binding name="BasicHttpsBinding_IService" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" />
</basicHttpsBinding>
</bindings>
<client>
<endpoint address="https://localhost:44370/service.svc" binding="basicHttpsBinding"
bindingConfiguration="BasicHttpsBinding_IService" contract="FileServer.IService"
name="BasicHttpsBinding_IService" />
</client>
</system.serviceModel>
then I am getting the below error
configuration binding extension 'system.servicemodel/binding.basichttpsbinding' could not be found. verify that this binding extension is properly registered in 'system.servicemodel/binding.basichttpsbinding' and that it is spelled correctly.
what can I do to solve this?

You are trying to use a HTTPS address with a HTTP binding, change the binding type to 'basicHttpsBinding'.

but I am getting the following error the provided uri scheme https is
invalid; expected 'http'
You try adding security mode to the binding, this change will allow you to use https instead of http.
<basicHttpBinding>
<binding name="BasicHttpsBinding_IService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport">
</security>
</binding>
</basicHttpBinding>

Related

WCF Endpoint does not use provided Https binding

I'm calling an external WCF service and am getting the following error message. "The provided URI scheme 'http' is invalid; expected 'https'. Parameter name: via"
here are the config sections pertaining to the service:
<client>
<endpoint address="https://www.odfl.com:443/wsRate_v4/RateService" binding="basicHttpBinding" bindingConfiguration="RatePortBinding" contract="OdflRateService.RateDelegate" name="RatePort" />
</client>
and the binding Section:
<bindings>
<basicHttpBinding>
<binding name="RatePortBinding">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
The assembly is calling the service is loaded into the app through reflection and the configuration values are in the main app web config. I don't know if this makes any difference but thought i should mention it.
Thanks!

WCF Service configuration HTTPS with CustomBinding

I needed a custombinding on a WCF Service to allow me to pass raw content to WCFRest service. Works great, but I can't get it to accept transport level security. I want https and basicauthentication as I use elsewhere. Endpoint looks like this:
<endpoint address="" behaviorConfiguration="web" contract="SmsService.ISmsReceive" binding="customBinding" bindingConfiguration="RawReceiveCapable"></endpoint>
customBinding looks like this:
<customBinding>
<binding name="RawReceiveCapable">
<security mode="Transport">
<transport clientCredentialType="Basic"/>
</security>
<webMessageEncoding webContentTypeMapperType="SmsService.RawContentTypeMapper, SmsService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<httpTransport manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
</binding>
</customBinding>
but system complains that mode attribute is not allowed in the security node. Without the security node all works great but it's not https.
Thanks
Ray
I think you need to drop the <security> element and then change the httpTransport element to httpsTransport as shown in the following example:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="RawReceiveCapable">
<webMessageEncoding webContentTypeMapperType="SmsService.RawContentTypeMapper, SmsService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<httpsTransport authenticationScheme="Basic" manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
</binding>
</customBinding>
</bindings>
The following link might be helpful:
http://msdn.microsoft.com/en-us/library/ms731818.aspx

BasicHttpBinding fails when sharing endpoint with WsHttpBinding - The server certificate is not provided

I have a WCF service endpoint that uses WsHttpBinding and BasicHttpBinding with different addresses to allow them to share the endpoint. There is no security on the BasicHttpBinding. The BasicHttpBinding works fine when my service and client are on the same machine. When they are on different machines the BasicHttpBinding fails and I get this error in the service's trace log: The service certificate is not provided. Specify a service certificate in ServiceCredentials.
The error stops happening if I remove the WsHttpBinding from the service's config.
Service's web.config:
<bindings>
<basicHttpBinding>
<binding name="MyBasicBinding"
maxBufferPoolSize="5242880"
maxReceivedMessageSize="5242880" />
</basicHttpBinding>
<wsHttpBinding>
<binding name="MyWsBinding"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="5242880"
maxReceivedMessageSize="5242880"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Message">
<message clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="MyService">
<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="MyBasicBinding"
contract="MyFramework.IMyService" bindingNamespace="http://MyFramework/Services/"/>
<!-- The basic binding fails when the WS binding is present.
If I remove the WS binding, the basic binding will work. -->
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="MyWsBinding"
contract="MyFramework.IMyService" bindingNamespace="http://MyFramework/Services/"/>
</service>
</services>
FYI I'm using a different address for the basic binding which allows the 2 bindings to share the same endpoint. The URL for WsHttpBinding is http://server/MyService.svc and for BasicHttpBinding is http://server/MyService.svc/basic.
Why does the presence of the WsHttpBinding force the BasicHttpBinding to expect a certificate?
When the service goes up it needs to ensure all endpoints are valid. Since one of the endpoints (The WSHttp one) uses certificate authentication, the server will not go up if this certificate is not defined. So the error is not related to the BasicHttp. That still does not explain why everything works if on the same machine, check if the exact same configuration is used.

WCF REST Service Template 4.0 "Bad Request"

I am trying to send a large json string to a WCF Service created with the WCF REST Service Template. If the string is longer 8000 characters I get a "HTTP/1.1 400 Bad Request" error. I have tried added this to my web config:
<bindings>
<webHttpBinding>
<binding name="httpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"/>
</webHttpBinding>
</bindings>
Any ideas?
You must also setup readerQuotas if you want to pass large strings:
<bindings>
<webHttpBinding>
<binding name="httpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="50000" />
</binding>
</webHttpBinding>
</bindings>

https with WCF error: "Could not find base address that matches scheme https"

I go to https://mywebsite/MyApp/Myservice.svc and get the following error:
(The link works if I use http:// )
"The service '/MyApp/MyService.svc' cannot be activated due to an exception during compilation. The exception message is: Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http].."
EDIT: So if I change address="" to address="https:// ..." then I get this error instead:
"Error: The protocol 'https' is not supported..... The ChannelDispatcher at 'https://.../Annotation.svc' with contract(s) '"Annotation"' is unable to open its IChannelListener."
Here's what my Web.Config looks like:
<services>
<service behaviorConfiguration="AnnotationWCF.AnnotationBehavior"
name="AnnotationWCF.Annotation">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Annotation"
contract="AnnotationWCF.Annotation" />
<endpoint address=""
binding="basicHttpBinding" bindingConfiguration="SecureTransport"
contract="AnnotationWCF.Annotation" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Annotation" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
<binding name="SecureTransport" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
I had this exact same problem. Except my solution was to add an "s" to the binding value.
Old:
binding="mexHttpBinding"
New:
binding="mexHttpsBinding"
web.config snippet:
<services>
<service behaviorConfiguration="ServiceBehavior" name="LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService">
<endpoint behaviorConfiguration="AspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webBinding"
contract="LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
It turned out that my problem was that I was using a load balancer to handle the SSL, which then sent it over http to the actual server, which then complained.
Description of a fix is here: http://blog.hackedbrain.com/2006/09/26/how-to-ssl-passthrough-with-wcf-or-transportwithmessagecredential-over-plain-http/
Edit: I fixed my problem, which was slightly different, after talking to microsoft support.
My silverlight app had its endpoint address in code going over https to the load balancer. The load balancer then changed the endpoint address to http and to point to the actual server that it was going to. So on each server's web config I added a listenUri for the endpoint that was http instead of https
<endpoint address="" listenUri="http://[LOAD_BALANCER_ADDRESS]" ... />
Make sure SSL is enabled for your server!
I got this error when trying to use a HTTPS configuration file on my local box which doesn't have that certificate. I was trying to do local testing - by converting some of the bindings from HTTPS to HTTP. I thought it would be easier to do this than try to install a self signed certificate for local testing.
Turned out I was getting this error becasue I didn't have SSL enabled on my local IIS even though I wasn't intending on actually using it.
There was something in the configuration for HTTPS. Creating a self signed cert in IIS7 allowed HTTP to then work :-)
I think you are trying to configure your service in a similar way to the following config. There is more information here: Specify a Service with Two Endpoints Using Different Binding Values. Also, other than for development, it's probably not a good idea to have both HTTP & HTTPS endpoints to the same service. It kinda defeats the purpose of HTTPS. Hope this helps!
<service type="HelloWorld, IndigoConfig, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null">
<endpoint
address="http://computer:8080/Hello"
contract="HelloWorld, IndigoConfig, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
binding="basicHttpBinding"
bindingConfiguration="shortTimeout"
</endpoint>
<endpoint
address="http://computer:8080/Hello"
contract="HelloWorld, IndigoConfig, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
binding="basicHttpBinding"
bindingConfiguration="Secure"
</endpoint>
</service>
<bindings>
<basicHttpBinding
name="shortTimeout"
timeout="00:00:00:01"
/>
<basicHttpBinding
name="Secure">
<Security mode="Transport" />
</basicHttpBinding>
</bindings>
In my case i am setting security mode to "TransportCredentialOnly" instead of "Transport" in binding. Changing it resolved the issue
<bindings>
<webHttpBinding>
<binding name="webHttpSecure">
<security mode="Transport">
<transport clientCredentialType="Windows" ></transport>
</security>
</binding>
</webHttpBinding>
</bindings>
I was using webHttpBinding and forgot to dicate the security mode of "Transport" on the binding configuration which caused the error:
<webHttpBinding>
<binding name="MyWCFServiceEndpoint">
<security mode="Transport" />
</binding>
</webHttpBinding>
Adding this in configuration fixed the problem.
Look at your base address and your endpoint address (can't see it in your sample code). most likely you missed a column or some other typo e.g. https// instead of https://