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:
WS_ctcs 

it still presents this WSDL:

WS_Before

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:
WS_After

The final result (WSDL-wise) is this:

Capture

All is fine and dandy!

6 comments:

Anonymous said...

Thanks. This is just what I needed

Khurdhi said...

Thanks.

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).

InRiver: Not loading your extensions?

(You really need to in the loop to appreciate the issue this post addresses). Man, I've been fighting this problem for hours before I ...