The Provided Uri Scheme 'Https' Is Invalid; Expected 'Http'. Parameter Name: Via

The provided URI scheme 'https' is invalid; expected 'http'. Parameter name--Immediate Help Needed

I changed cleint configuration bindings section equal to service configuration. I changed client configuration as given below.

        <bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICARetriever">
<security mode="Transport">
</security>
</binding>
</basicHttpBinding>
</bindings>

once i did this i got access denied exception. Then i changed app pool identity from NetworkService to LocalSystem. And it worked like a charm I got the response back. I tried again changing NetworkService to Defaultappoolidentity in app pool then also it worked. But if i remove from client configuration it is giving Error like "provided URI scheme 'https' is invalid; expected 'http'.".Let me know if you guys have any other thoughts on this.

The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via for HTTPS

I found the answer with this link. The key was to set the following parameters in the custom binding:

<security allowInsecureTransport="true" enableUnsecuredResponse="true">

The provided URI scheme 'http' is invalid; expected 'https'. Parameter name

In WCF, we should configure an extra service endpoint for HTTPS protocol, which requires the transport layer security mode.

    <services>
<service name="WcfService1.Service1">
<!--please pay attention to that apply the binding configuration by means of bindingConfiguration property.-->
<endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" bindingConfiguration="mybinding"></endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="mybinding">
<security mode ="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>

The below configuration supports both HTTP protocol and HTTPS protocol.

  <system.serviceModel>
<services>
<service name="WcfService1.Service1">
<!--please pay attention to that apply the binding configuration by means of bindingConfiguration property.-->
<endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" bindingConfiguration="mybinding"></endpoint>
<endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="mybinding">
<security mode ="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

We could also use ProtocolMapping section to simplify the configuration. The below configuration support both HTTP and HTTPS protocol.

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<protocolMapping>
<add binding="basicHttpBinding" scheme="http"/>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
</system.serviceModel>

Official document.

https://learn.microsoft.com/en-us/dotnet/framework/wcf/simplified-configuration

Feel free to let me know if there is anything I can help with.

WCF: The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via when i call IInternal proxy = factory.CreateChannel(); on Client

You have to tell the client to use a secure transport channel so that it uses https instead of http. This is true because the binding settings at the client must match the ones at the service side.

You can do this via configuration in the app.config file of the client, or you can do it via code like this:

var ws_http_binding = new WSHttpBinding();

ws_http_binding.Security.Mode = SecurityMode.Transport;

ChannelFactory<IInternal> factory =
new ChannelFactory<IInternal>(
ws_http_binding,
new EndpointAddress("https://MyMachine:8733/IInternal"));

var channel = factory.CreateChannel();


Related Topics



Leave a reply



Submit