Changing the targetNamespace of generated wsdl

Mar 30, 2010 at 6:05 PM

I downloaded the v1.0.7 and tried creating a WCF service using a contract first approach. I was able to build the code and publish it to IIS and the generated wsdl looked good. The only thing that I thought was not correct is in the generated wsdl the targetnamespace is "". The wsdl from which I started is imported in this wsdl and has the correct namespace. Here is snapshot of generated wsdl:

<wsdl:definitions name="MemberServices" targetNamespace="" xmlns:wsdl="" xmlns:wsa10="" xmlns:wsx="" xmlns:soap12="" xmlns:wsu="" xmlns:wsp="" xmlns:wsap="" xmlns:msc="" xmlns:wsa="" xmlns:wsam="" xmlns:wsaw="" xmlns:tns="" xmlns:soap="" xmlns:i0="http://MemberServicesLibrary/MemberServices" xmlns:xsd="" xmlns:soapenc="">
<wsdl:import namespace="http://MemberServicesLibrary/MemberServices" location=""/>
<wsdl:binding name="CustomBinding_IMemberServices" type="i0:IMemberServices">

Is there a way to set the targetNamespace to something other than

Apr 14, 2010 at 3:18 PM

When building the WSDL using the wizard if you provide a namespace on the first wizard page this will be used as the targetNamespace in your WSDL.

Then when generating your service code the Namespace property of the ServiceContractAttribute on the service interface will also be given that namespace. That should cause the correct targetNamespace to be provided in the WSDL that is automatically generated by WCF.