When you publish a Microsoft Windows workflow as a Web service in Microsoft Visual Studio 2005, the namespace for the Web service is always "http://tempuri.org."
This problem occurs when a workflow uses Web service activities, such as the WebServiceInputActivity activity, the WebServiceOutputActivity activity, and the WebServiceFaultActivity activity. In the workflow assembly, a Web service wrapper is generated and then is compiled. The name of the Web service wrapper is as follows:
<WorkflowNamespace>.<WorkflowName>_WebService
When the file is generated, no namespace is specifed. The default namespace, http://tempuri.org, is used instead. During the build process, the Web service wrapper is both generated and deleted. You cannot configure this wrapper or specify a namespace.
To resolve this problem, create a new class in the Web service project. The class derives from the generated Web service wrapper class. After you publish the workflow as a Web service, apply the namespace attribute to the class that derives from the Web service wrapper class.
- Make sure that the workflow project has been published. If the workflow project has not been published, right-click the workflow project, and then click Publish as Web Service.
- In Solution Explorer, right-click the generated Web service project, click Add ASP.NET Folder, and then click App_Code.
- Right-click the App_Code folder, and then click Add New Item.
- Click Class, type WorkflowResolution.cs in the Name box, and then click Add.
- When the WorkflowResolution.cs file opens, replace the contents of the file by using the following code:
using System.Web.Services;
[WebService(Namespace = "http://MyNamespace/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class MyWebService : WorkflowLibraryName.WorkflowName_WebService
{
} Note Replace http://MyNamespace/ with the namespace that you want. - Edit the class declaration. Change the base class so that the base class refers to the generated Web service wrapper class for the workflow project. Use the following format:
<WorkflowNamespace.WorkflowName>_WebService
Do not edit the WebServiceBinding attribute. Other configurations have not been tested. Other configurations are not supported. - Edit the .asmx file for the Web service so that it refers to the new class, as follows:
<%@WebService Class="WorkflowResolution" %>
- Click the Build menu, and then click Rebuild Solution.
Note You have to follow these steps only one time.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Steps to reproduce the problem
- In Visual Studio 2005, click the File menu, click New, and then click Project.
- Expand Visual C#, click Workflow, click Sequential Workflow Library, type WorkflowLibrary1 in the Name text box, and then click OK.
- In Solution Explorer, right-click Workflow1.cs, and then click View Code.
- Locate the following code:
public sealed partial class Workflow1: SequentialWorkflowActivity
{
public Workflow1()
{
InitializeComponent();
}
} - Replace the code that you located in step 4 with the following code:
interface WSInterface
{
void DoWork();
}
public sealed partial class Workflow1: SequentialWorkflowActivity
{
public Workflow1()
{
InitializeComponent();
}
} - In Solution Explorer, right-click Workflow1.cs, and then click View Designer.
- Drag a WebServiceInputActivity control onto the Workflow1.cs design window.
- For the InterfaceType property, specify the interface that you created in step 5. Set the IsActivating property to a value of true, and then specify the DoWork method as a value for the MethodName property.
- In Solution Explorer, right-click WorkflowLibrary1, and then click Publish as Web Service.
- In the confirmation dialog box that appears, click OK.
- In Solution Explorer, right-click WorkflowLibrary1.Workflow1_WebService.asmx, and then click View in Browser.
You receive the following message:
This web service is using http://tempuri.org/ as its default namespace.
Recommendation: Change the default namespace before the XML Web service is made
public
Article ID: 927845 - Last Review: March 22, 2007 - Revision: 1.1
APPLIES TO
- Windows Workflow Foundation
| kbtshoot kbcode kbprb KB927845 |