If you have been using Windows Workflow Foundation to build web service business logic, you may be using the publish-as-web-service tool that is part of the Visual Studio extensions for Windows Workflow Foundation. How it works is if you have a workflow model defined in a Visual Studio project you can right click on the project and choose "Publish as Web Service" from the menu. The tool will add a new project to your solution which is a web service. This new web service will execute the workflow. Your workflow model must have at least one WebServiceInput activity in it to do this.
The thing that many people have been finding is that it uses the default namespace of TEMPURI.ORG and it's not configurable. Well here's how you can change the namespace with a minimum of fuss. We're planning a KB article with a more official description of this.
1) First the web service is generated code which is compiled and you are left with the DLL only. The source is deleted by default. You want to change that. There's a registry key that you can set to keep the source for the web service. Usual disclaimers apply about changing the registry on your machine. Here's the key to set:
- HKLM/SOFTWARE/Microsoft/NET Framework Setup/NDP/v3.0/Setup/Windows Workflow Foundation
- Create a new REG_DWORD key called KeepTempFiles and set its value to 1.
2) Next go ahead and publish your web service normally as described above. This will create the source and compile it, but it will not be deleted. Right click on your web service project and choose ASP.NET Folder -> App_Code. Now you need to go and fetch the generated source from your Temp directory. My temp directory on Windows Vista is at C:\Users\pandrew\AppData\Local\Temp. Find the recently generated .CS file there and copy it. My test one here was called 077px_9s.cs. Put this file into the App_Code folder using explorer. Now edit the .ASMX file in your project and add the CodeBehind="~/Filea.cs". See I renamed the file from 077px_9s.cs to Filea.cs. My test WorkflowLibrary1.Workflow1_WebService.asmx file now looks like this:
<%@ WebService CodeBehind="~/Filea.cs" Class="WorkflowLibrary1.MyClass" %>
3) The final step is to open your newly added code behind file and add the new namespace into the file. Just add the WebService attribute to the class and specify the namespace in that attribute, something like this:
public class MyClass : WorkflowWebService
Once you've done that you can recompile the project and you should have a web service that is implemented by a workflow model and your chosen namespace.
PS: This is my first blog entry written in Word 2007.