Jun 092012
 

Today I’ve spent several hours trying to create a Domain Service for Windows Azure and having a Metro-style App consume that service.

Creating the Domain Service is easy, just add a new Domain Service class, create a public method inside it, build, done. You can open it with the well-known URL scheme http://servername/namespace-servicename.svc. But doing that is not enough so that clients can consume it. The default “you have created a service” page offers you a link to the WSDL version of the service, where the URL scheme is like this: http://servername/namespace-servicename.svc?wsdl. But there is the problem. Visiting that URL doesn’t show any WSDL, it shows the “you have created a service” page again.

After hanging around in google for a few hours, I finally found the missing puzzle piece… you have to create a SOAP endpoint, in order to get the automatic WSDL generation working! Just add the following lines to your Web.Config file:

<system.serviceModel>
  <domainServices>
    <endpoints>
      <add name="Soap" transmitMetadata="true" type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </endpoints>
  </domainServices>
</system.serviceModel>

After having done that, you can go to your client app, Add Service Reference, give the URL to the .svc file, and you’re done.

 Posted by at 11:12 am