domenica 16 settembre 2012

Expose the Domain Service to other types of clients, formerly "SOAP Endpoint"

Don't believe who say that it's easy to expose a Domain Services using SOAP endpoints. Expose a RIA Domain Service to other clients, glad to the very infrastructure of RIA Services, it's not painless. First of all, it needs some changes to the web.config, that's not a problem at all.
You will get the very painful steps just when try to connect to your domain services. The RIA endpoints are automatically generated by the service itself, so, you have no way to control them (some workarounds exists but I feel like they can create problems in future releases of RIA Services, or even in different configurations, because they're hack on IIS URL registration).

RIA Services introduced SOAP endpoints with RIA Services Toolkit. You need to download and install the toolkit for the SOAP endpoint to work.
You can found RIA Services and RIA Toolkit at this url:

You can use SOAP endpoint to expose your domain service to Windows Phone 7, WPF, ASP.NET and even Java, iOS, Android and whatever you want devices.

First, add a reference to the Microsoft.ServiceModel.DomainServices.Hosting assembly.
First thing to do after is to enable SOAP Endpoints of your Domain Services. This can be done just adding an endpoint named "SOAP" to the endpoint collection in DomainServices section, contained inside the system.ServiceModel main section of the web.config:

<add name="Soap" type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

this will enable the automatic SOAP endpoint for RIA services.
Once enabled, the endpoint can be reached using the following url template:

http://<hostname>:[port]/<domain service class namespace>-<domain service class name>.svc?wsdl

Remember to replace every dot inside the namespace and class names with minus ("-") signs. 
In the case of our example, we have:


This will activate the SOAP endpoint of the service, allowing the generation of proxies from Java and other .NET application than Silverlight apps.

NOTE: I will upload to my host site the source of the example. I cannot do it now as I'm out of office, but I will do this soon.

Nessun commento:

Posta un commento