How to get rid of https://tempuri.org in a Workflow Service

Edit: Ignore this really old post and view How to eliminate tempuri.org from your service WSDL

Somebody was asking earlier today how to eliminate the namespace https://tempuri.org from their WSDL with a WorkflowService.

I had no idea but soon enough somebody from the team came up with the answer.  It was something you would never guess in a million years so I decided this has to go on the blog.

When you create a WorkflowService the namespace of your service is declared as a part of the ServiceContractName.  For example, in the Introduction to Workflow Services Hands On Lab You create a service named SubmitApplication.xamlx and set the ServiceContractName to {https://contoso.com/hr/}IApplicationService

Everything inside the curly braces is the namespace.  Everything after is the contract name.  Fine – this looks good right?  I assumed that was all you would need but then…  Look at this WSDL.

 <wsdl:definitions name="SubmitApplication" targetNamespace="https://tempuri.org/" >

 

Doh!  There it is, right in front of me…  Now other parts of the WSDL are using the correct namespace so maybe it is not that big of a deal but still, I want to get rid of https://tempuri.org!!

Ready for the solution?  It’s non-obvious but here goes...

The name of the WorkflowService is actually an XName which means it includes a namespace.  If you don’t provide a namespace, guess what you get?  https://tempuri.org!

If you want to get rid of it, you have to use a namespace prefix.  Earlier when I set the ServiceContractName it created an xmlns declaration in the XAML for me. It’s buried in the long list of xmlns declarations but you will find it if you search for p: (I deleted a bunch of stuff below so you can see it.

Edit: 5/3/11 - You can set the XName in the WorkflowService Name property by using braces {https://contoso.com/hr}SubmitApplication that way you won't have to edit the XAML directly.

 <WorkflowService Name="SubmitApplication" xmlns:p="https://contoso.com/hr/" >

 

Now to apply this namespace to the Name property you have to edit the XAMLX file in the XML editor (the designer doesn’t allow this).  The fix is so simple…

 

 <WorkflowService Name="p:SubmitApplication" xmlns:p="https://contoso.com/hr/" >

 

Notice the namespace prefix?  Just put a p: in front of the name and you are all done!

 

Now look at the WSDL.

 <wsdl:definitions name="SubmitApplication" targetNamespace="https://contoso.com/hr/" >

Wohoo!

Edit: 6/5/2010

Unfortunately there is still one tempuri.org in the WSDL and for the life of me I can't find a way to get rid of it.  I'll let you know if I find out how to eliminate it.

Edit: 4/13/2011

Sadly... still I must report there is just no way to get rid of this tempuri.org.  If this really bothers you, please submit a bug (or vote on an existing one at https://connect.microsoft.com)

Edit: 5/3/2011

An interesting blog post on eliminating tempuri.org from WCF Services is here.  The solution won't work for Workflow Services but it's good information anyway.

Edit: 5/12/11 Edit: Ignore this really old post and view How to eliminate tempuri.org from your service WSDL