简体   繁体   中英

Error when configure HTTPS in WCF Service

I have a Wcf Service in VS 2010, .NET 4.0.

IIS site is virtual directory.

I try configure it and access it using https

https://pruebaslba.xxxx.net/ServicioPyS/Service.svc?wsdl

But I get error

Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].

or

Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http].

Googleing, I have seen several alternatives about configurations: serviceMetadata, bindings, baseAddresses, ..

I try different configurations, but I get the same error:

serviceMetadata

<serviceMetadata httpGetEnabled="false or true" httpsGetEnabled="true" />

bindings

I use <security mode="Transport">

 <bindings>

      <basicHttpBinding>
        <binding name="SecureTransportOnly">
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
          </security>
        </binding>

        <binding name="NoSecure">
          <security mode="None"><transport clientCredentialType="None"/></security>
        </binding>

      </basicHttpBinding>

      <wsHttpBinding>
        <binding name="SecureTransportOnly">
          <security mode="Transport">
              <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
          </security>
        </binding>

      </wsHttpBinding>
    </bindings>

endpoint

 <endpoint
            address=""
            binding="basicHttpBinding"
            bindingConfiguration="SecureTransportOnly"
            name="xxxActualServiceEndPoint"
            bindingNamespace="https://pruebaslba.xxxx.net/ServicioPyS"
            contract="IxxxActualService">

mex

<endpoint address="mex" binding="mexHttpBinding o mexHttpsBinding" contract="IMetadataExchange"/>

And I tried too:

  <!--<host>
          <baseAddresses>
            <add  baseAddress="https://pruebaslba.xxxx.net o https://pruebaslba.xxxx.net/ServicioPyS"/>
          </baseAddresses>
        </host>-->

          <!--<identity>
            <dns value="localhost" />
          </identity>-->

I tried, I think, almost configurations that I've found in forums. I don't know the solution.

UPDATE I get more information about it. The website is in 2 servers (PreProduction environment): preiis01 and preiis02 . SSL is not enabled.

I can Access to http://preiis01/ServicioPyS/Service.svc?wsdl All is OK by http.

https://pruebaslba.xxxx.net/ServicioPyS/Service.svc?wsdl is public url about NLB (load balanced, I think, F5). In NLB, SSL is configured. I dont know more information, only IT departament has all information.

The problem is about WSDL

http://preiis01/ServicioPyS/Service.svc?wsdl

<wsdl:service name="ActualService">

<wsdl:port name="ActualServiceEndPoint"binding="i0:ActualServiceEndPoint">

<soap:addresslocation="http://preiis01/ServicioPyS/Service.svc/Service.svc" />

</wsdl:port>

</wsdl:service>

url WSDL in NLB hast problema with soap:address location part and is not generated right (set http, and not https)

https://pruebaslba.xxxx.net/ServicioPyS/Service.svc?wsdl

<wsdl:service name="ActualService">

<wsdl:port name="ActualServiceEndPoint"binding="i0:ActualServiceEndPoint">

<soap:addresslocation="http://pruebaslba.xxxx.net/ServicioPyS/Service.svc/Service.svc" />

</wsdl:port>

</wsdl:service>

Quickly solution was modify manually WSDL (singlefile) and set https in soap:addresslocation part, in new url https://pruebaslba.xxxx.net/ServicioPyS/WSDL/ServiceWsdlModificado.Single.wsdl

https://pruebaslba.xxxx.net/ServicioPyS/WSDL/ServiceWsdlModificado.Single.wsdl

<wsdl:service name="ActualService">

<wsdl:port name="ActualServiceEndPoint"binding="tns:ActualServiceEndPoint">

<soap:addresslocation="https://pruebaslba.xxxx.net/ServicioPyS/Service.svc/Service.svc"/>

</wsdl:port>

    </wsdl:service>

I think, there is another good solution with good practices. I don't know.

Website in IIS has not SSL enabled, and NLB has SSL.

Maybe “SSL pass-through” , I don't know

http://blog.tonysneed.com/2012/06/18/building-scalable-and-secure-wcf-services/

Any suggestions?

There error says that your base address uses the 'http' scheme, when it needs instead to use 'https.' When hosting in IIS, the address is configured in IIS, rather than the hosts element in config.

That means you need to set up SSL in IIS: http://www.iis.net/learn/manage/configuring-security/how-to-set-up-ssl-on-iis .

Then open Visual Studio as Administrator, then go to the Web tab of project properties and change the base address there to use https with Local IIS. VS will create a virtual directory for you with the https scheme.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM