Publish WCF Service on IIS

By: Nicklas Møller Jepsen

Recently I needed to publish a WCF service on an IIS. This progress I quite smooth when you just need to access the WCF service locally, but ones you need to publish the service on the great Internet, things are a little more difficult.

Publishing the WSDL

The ‘WSDL generation strategy’ when using WCF is that you get multiple documents to describe your service. This can lead to some problems if you’re just publishing without making some customizations.

Have a look at the wsdl:types:

    <xsd:schema targetNamespace="http://tempuri.org/Imports">
        <xsd:import schemaLocation="http://localhost/Service/Service.svc?xsd=xsd0"namespace="http://tempuri.org/"/>
        <xsd:import schemaLocation="http://localhost/Service/Service.svc?xsd=xsd2"namespace="http://schemas.datacontract.org/2004/07/Service.Interface"/>

Notice the localhost, that will definitely cause some trouble if you need to consume the WSDL from an external machine.

How to fix this?

There’re two ways to solve this (if not more):

  • Fix the host name (this post)
  • Generate a single WSDL (future post)

Fix the host name

It’s actually the IIS who are responsible of the host name. Therefore we need to configure the bindings for the web site the WCF service is hosted on.

Go to IIS Manager, right click the web site and choose Edit bindings:


Now click the Add button and enter the external host name or ip where your service/wsdl will be available from:


Restart the web site and go to http://mydomain.com/serviceAlias/Service.svc?wsdl and your should see that the imports are now using the external host name.

Generate a single WSDL

You can also choose to generate a single WSDL file for your WCF service. I will post about that later, meanwhile take a look at this great article that describes it – although I find it a bit to complex and therefore are going to write my own post about it when the time comes Smile