19 October, 2009

WCF and WSDL: targetNamespace

WCF and WSDL is two different things that sometimes brings in troubles.

I today struggled a bit with being allowed to set the targetNamespace of the WSDL being generated from WCF. Even you set the [namespace]-property in your contracts, the WSDL being generated does not listen to this.

If you click the second image, you see where the problem lies. Even I have attributed the ServiceContract like this:

it still presents this WSDL:


The solution is found in ServiceBehavior configuration! To control what is emitted as targetNamespace, you need to specify this in the ServiceBehaviour-configuration like this:

The final result (WSDL-wise) is this:


All is fine and dandy!


Anonymous said...

Thanks. This is just what I needed

Khurdhi said...


Anonymous said...

great, just what i am finding.

Anonymous said...

great, just what i am finding.

Kamil Durkiewicz said...

But you still have:

<wsdl:import namespace="http://tempuri.org/"...

in the 8th line of the wsdl.
Do you know how it can be solved?

Claus Konrad said...

Good point!
I do not know from the top of my head; but I would expect it to find it somewhere in the same area (ServiceBehavior).

iPhone/XCode - not all cases are equal!

This bit me! Having made some changes to an iPhone application (Obj-C); everything worked fine in the simulator. But, when deploying the s...