Search code examples
c#wcfhttpswcf-securitybasichttpbinding

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


Hello I tried all the solutions provided in stack over flow. I am getting "The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via" error. Service is rumnning fine in IIS7 and i am getting this error when ever i try to consume this service.Please see my wcf service configuration and client configuration.

  <?xml version="1.0"?>
    <configuration>
    <system.web>
    <compilation targetFramework="4.0"/>
    <httpRuntime/>
    </system.web>
    <system.serviceModel>
    <serviceHostingEnvironment >
    <serviceActivations>
    <add factory="System.ServiceModel.Activation.ServiceHostFactory"         relativeAddress="./CARetriever.svc" service="CARetrieverInterface.CARetriever"/>
      </serviceActivations>
    </serviceHostingEnvironment>

    <behaviors>
      <serviceBehaviors>
        <behavior name="MyTesting">
          <!-- Other options would go here -->
          <useRequestHeadersForMetadataAddress>
            <defaultPorts>
              <add scheme="https" port="443" />
            </defaultPorts>
          </useRequestHeadersForMetadataAddress>
          <serviceMetadata httpsGetEnabled="True"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <services>
      <service name="CARetrieverInterface.CARetriever" behaviorConfiguration="MyTesting">
        <endpoint address="https://sspumptest.dhr.state.ga.us/testcode/CARetriever.svc" binding="basicHttpBinding" contract="CARetrieverInterface.ICARetriever" bindingConfiguration="secureHttpBinding">
          <identity>
            <dns value="sspumptest.dhr.state.ga.us" />
          </identity>
        </endpoint>
        <!--<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />-->
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="secureHttpBinding">
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>
</configuration>

My client configuration is given below.

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ICARetriever">             
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://sspumptest.dhr.state.ga.us/testcode/CARetriever.svc"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICARetriever"
          contract="CARetrieverRef.ICARetriever" name="BasicHttpBinding_ICARetriever" />
    </client>
  </system.serviceModel>
</configuration>

Solution

  • 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.