In this blog I’ll describe the manual deployment process for secure WCF service on windows server 2008 R2 hosted on IIS, I will cover some common issues as well that you may face during the deployment
First you have to prepare the server to host WCF service as follows:
Install .net framework 4.5 by downloading and installing it from Microsoft site: http://www.microsoft.com/en-us/download/details.aspx?id=30653
On deployment server add web server role from server manager
then Add the following role services to web server role
After adding the role services and web server role ,the IIS will be shown in web server node from server roles
Next we will prepare the IIS host for the service, first we create app pool and set the identity for it
Then we add application on default websites assuming you will deploy to IIS default websites group.
Now to secure the service channel we have to install certificate on IIS server, this could be accomplished by selecting the server node from IIS server then select server certificate
From you here you could install the certificate to server
Now after installing the certificate we configure site binding by adding HTTPS on server bindings and select installed SSL certificate that is created from trusted Certificate authority
Check and Install latest updates on server
The server is ready to host the WCF service ,now am assuming you are done with development and your service is ready and configured as secure service
We will publish the service using visual studio to local desk drive , this could be accomplished by Right click on web project on visual studio that host WCF service then publish to local desk
Now we will copy the generated service files to production server created IIS website , the generated files mainly consist of bin folder that holds the DLLs configuration file and svc service files
Now if you face error “unrecognized attribute target framework” once you navigate to service, this is mainly caused by selecting .net framework 2.0 from app pool ; Just change the .NET framework version from App pool
another common error you may face could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding
This is mainly caused by missing HTTPs configuration on IIS server, if you configure your service security with
<security mode="Transport">
</security>
Or
<security mode=" TransportWithMessageCredential">
</security>
You have to configure HTTPs on IIS
other common issue you may face is Having internal server name in URL and WSDL URL which cause clients not being able to add service reference
To fix this add <useRequestHeadersForMetadataAddress/> to behavior section in WCF configuration
Remove address="" in from endpoint configuration
Add host header in IIS with service URL