Showing posts with label wsdl. Show all posts
Showing posts with label wsdl. Show all posts

Monday, January 12, 2009

How to get rid of http://tempuri.org/ in WCF WSDL

"Each XML Web Service needs a unique namespace in order for client applications to distinguish it from other services on the Web. By default, ASP.Net Web Services use http://tempuri.org/ for this purpose. While this suitable for XML Web Services under development, published services should use a unique, permanent namespace." (http://tempuri.org)

By default WCF maps all service operations to the targetnamespace http://tempuri.org/ .
The problem with this approach occurs as soon as you as you need to uniquely indentify a service operation and you have more than just one service. e.g. in Biztalk or Microsoft Managed Service Engine.
Guess you have a 2 services both with the DoSomeThing() function. As both use the http://tempuri.org namespace for their operations, you can't uniquely indentify them.

To get rid of http://tempuri.org/ in your WSDL in WCF do the following:

1.) In your ServiceContract attribute constructor define the Namespace property.

[ServiceContract(Namespace = "http://myservice.com")]

public interface IMyService

2.) For your ServiceClass create the ServiceBehavior attribute with Namespace property

[ServiceBehavior(Namespace = "http://myservice.com")]

class MyService : IMyService

3.) In all your bindings set the bindingNamespace property

<endpoint binding="basicHttpBinding" bindingNamespace="http://myservice.com"....

Tuesday, November 18, 2008

Bug in Visual Studio 2008 WSDL Interpreter

When I started working with Flat-WSDL we soon came to a phenomenon where our list types suddenly become converted to

ArrayType[]

instead of

List<arraytype>

It took a while to drill down the cause to the following.

A common wsdl:types section looks like this:

<wsdl:types>
<xsd:schema>
</xsd:schema ....>
<xsd:schema>
</xsd:schema ....>
</wsdl:types>

but whenever there is the following section in the WSDL

<wsdl:types>
<xsd:schema ....>
</xsd:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" ....>
</xs:schema>
</wsdl:types>

you can not switch the ListTypes anymore. They will all be ArrayType[] . This applies for the ServiceReference as well as for svcutil that simply ignores the /ct: Parameter .

Both WSDL descriptions are perfectly valid as both tokens xsd: and xs: reference the http://www.w3.org/2001/XMLSchema Namespace and hence are synonyms.

I reported the bug to Microsoft using Connect (MSConnect ID:387245). But I heavily disagree with their answer, which basically says "It's not a bug it's a feature". You should find some samples wsdls there.