Web.config settings to get WCF 4.0 to work with HTTPS
To note: I have been told that you should not run WCF in both a HTTP and HTTPS protocol world. Even when in development. Anyways, that is the approach I am taking. So If I have to migrate my web.config file from a development environent to a production environement. I WILL MAKE SOME MINOR ADJUSTMENTS TO THE WEB.CONFIG File
NOTICE: THIS IS FOR STUDIO 2010 (.net 4.0). If you are using an earlier framework(such as 3.5), please keep searching and do not use this reference:
July 28, 2010
HOW TO RUN HTTPS with WCF (windows comunication foundation)
Product and service descriptions are useful when people are shopping, but it's a great idea to give them some interesting "between the lines" information.
Give tips that your employees or customers have discovered, ideas on how to maximize use, or suggestions for modifications. This little bit of extra effort can help drive interest and sales.

FOR HTTPS YOU HAVE TO USE BINDINGS
(to go between HTTP AND HTTPS you have to change one thing in the serviceBehaivor
httpsGetEnabled="true" (FOR HTTPS)
httpGetEnabled="true" (FOR HTTP)
This web.config file build on my other web.config file I mentioned
here: http://douglubey.com/Jquery_WCF4_JSON_webConfig_Settings_Plus_Bindings_For_WebHttp_And_BasicHttp.aspx
AND HERE IS AN ARTICLE I HAVE WRITTEN FOR XML COMMUNICATION FOR FLEX
ADOBE FLEX AND DOTNET XML WEB SERVICES RETURNING XML RESULTS mx WebService TAG
THE ONLY REAL DIFFERENCES ARE:
1>I am now using protocol /port bindings
2>ASSIGNING THE BINDINGS TO THE ENDPOINTS
3>CHANING HTTPGETENABLED to HTTPSGETENABLED (WHICH HAS TO BE DONE....if you are testing on non-https site)
4>I ALSO ADDED NAMESPACES so that tempuri is not located anywhere in the wSDL [NOTICE: when using namespaces(NOT VB.NET /dotnet classes)] These apply to the publicly shown NAMESPACE which is viewed in a WSDL file. ?WSDL
<system.serviceModel> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> <bindings> <basicHttpBinding> <binding name="basicHttpBinding"> <security mode="Transport" /> </binding> </basicHttpBinding> <webHttpBinding> <binding name="webHttpBinding"> <!-- FOR SECURE-HTTPS --> <security mode="Transport"> <transport clientCredentialType="None" proxyCredentialType="None"/> </security> <!-- FOR NORMAL (DO NOTHING)-->
</binding> </webHttpBinding> <wsHttpBinding> <binding name="wsHttpBinding">
<!-- FOR SECURE-HTTPS --> <security mode="Transport"> <transport clientCredentialType="None" proxyCredentialType="None"/> </security> <!-- FOR NORMAL (DO NOTHING)-->
</binding> </wsHttpBinding> </bindings> <services> <!-- if using a namespace the service file(svc) needs to change as well is the class and interface files too--> <service name="WebApplication.myHelloWorld" behaviorConfiguration="AllMyServiceBehaviors"> <!-- FLEX 4 --> <endpoint bindingNamespace="www.mycompany.com.services"
address="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="WebApplication.ImyHelloWorld" binding="basicHttpBinding"> </endpoint> <!-- JAVASCRIPT /JQUERY/ AJAX --> <endpoint bindingNamespace="www.mycompany.com.services"
address="webHttpBinding" bindingConfiguration="webHttpBinding" behaviorConfiguration="scriptEndPointBehavior" contract="WebApplication.ImyHelloWorld" binding="webHttpBinding"> </endpoint> <!-- OTHER BINDINGS --> <endpoint bindingNamespace="www.mycompany.com.services"
address="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="WebApplication.ImyHelloWorld" binding="wsHttpBinding"> </endpoint>
<!-- WSDL GENERATION -->
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/> <!-- FOR NORMAL <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> -->
</service> <!-- if using a namespace the service file(svc) needs to change as well is the class and interface files too--> <service name="WebServicesTest.Service" behaviorConfiguration="AllMyServiceBehaviors"> <!-- FLEX 4 --> <endpoint bindingNamespace="www.mycompany.com.services"
address="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="WebServicesTest.IService" binding="basicHttpBinding"> </endpoint> <!-- JAVASCRIPT /JQUERY/ AJAX --> <endpoint bindingNamespace="www.mycompany.com.services"
address="webHttpBinding" bindingConfiguration="webHttpBinding" behaviorConfiguration="scriptEndPointBehavior" contract="WebServicesTest.IService" binding="webHttpBinding"> </endpoint> <!-- OTHER BINDINGS --> <endpoint bindingNamespace="www.mycompany.com.services"
address="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="WebServicesTest.IService" binding="wsHttpBinding">
<!-- WSDL GENERATION -->
<endpoint bindingNamespace="www.mycompany.com.services"
address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/> <!-- FOR NORMAL <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> -->
</endpoint> </service> </services> <behaviors> <serviceBehaviors> <behavior name="AllMyServiceBehaviors">
<serviceMetadata httpsGetEnabled="true" httpsGetUrl=""/> <!-- FOR NORMAL <serviceMetadata httpGetEnabled="true" /> -->
<serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="scriptEndPointBehavior"> <webHttp/> <enableWebScript/> </behavior> </endpointBehaviors> </behaviors>
</system.serviceModel>
NOTICE:
NAMESPACES MAY IMPACT THE ACCEPTANCE OF THE WSDL
SO WHEN YOU VIEW THE WSDL. YOU MAY WANT TO CHECK
AND ENSURE YOUR DOMAIN URI (URL) MATCH THE LOCATION
OF WHERE THE REAL SVC FILES ARE LOCATED.
targetNamespace="http://tempuri.org/" (will probably not be acceptable for SSL TO WORK)
IN THE WEB.CONFIG file you notice all the bindingNamespace="www.mycompany.com.services"
ALSO ADD THE NAMESPACES TO THE CLASS FILE AND INTERFACE FILES.
notice:
IF YOU HAVE MORE THAN 1 INTERFACE PER FILE
or
IF YOU HAVE MORE THAN 1 CLASS PER FILE
(YOU HAVE TO INDICATE THE NAMESPACE ON INDIVIDUAL CLASS OR INTERFACE TOO.
If you do not do it on both files. SOME READERS of the WSDL will indicate problems
with interpreting the SOAP BODY.
in service.vb
Namespace WebServicesTest <ServiceBehavior(Namespace:="www.mycompany.com.services")> Public Class Service
Implements IService
Public Function getTestOne() As System.Collections.Generic.List(Of String) Implements IService.getTestOne
'CODE
Return locList End Function
End Class End Namespace
in Iservice.vb
Namespace WebServicesTest <ServiceContract(Namespace:="www.mycompany.com.services")> Public Interface IService
<OperationContract()>
Function getTestOne() As System.Collections.Generic.List(Of String) End Interface
' Use a data contract as illustrated in the sample below to add composite types to service operations.
<DataContract(Namespace:="www.mycompany.com.services")> Public Class StudentRecord
<DataMember()>
Public Property firstname() As String
<DataMember()>
Public Property lastname() As String
<DataMember()>
Public Property studentid() As String
End Class
End Namespace
AND IF YOU HAVE MORE THAN ONE CLASS OR INTERFACE PER FILE
YOU HAVE TO ADD THE PUBLICLY AVAILABLE NAMESPACE ON EACH PAGE
Search:
wcf services https binding
wcf4 services https binding 2010
how to wcf4 https registered base address schemes are [https]
https webconfig file settings for ssl (secure socket layer)
how to setup a web.config file for communication to https
how to enable https to speak with WCF (windows communication foundation)
directions on making SSL (HTTPS) work with SVC files
WEB CONFIG WCF HTTPS
http://wcf4templates.codeplex.com/ (THIS I COULD NOT GET INSTALLED)
OTHER ERRORS I RECEIVED:
Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding. Registered base address schemes are [https].
HttpsGetUrl must be a relative URI or an absolute URI with scheme 'https'. 'http://www.myCompany.com/APPS/myHelloWorld.svc' is an absolute URI with scheme 'http'.
The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address. Either supply an http base address or set HttpGetUrl to an absolute address.