Exposing a Workflow As a Web Service (From Microsoft Elearning)

A third approach is to publish your workflow as a Web service. This means that ASP.NET applications, desktop applications, and other applications can use the workflow just as they would make requests to any other Web service. To expose a workflow and a Web service you must satisfy the following requirements. Click each requirement to view more details.
You can only expose a workflow as a Web service if you include the WebServiceReceive activity in the workflow. The WebServiceReceive activity passes the parameters passed to the Web service into the workflow.
You must create an interface in the code-behind file of the workflow class. You can only call the methods listed in this interface through the Web service:
Public Interface ILoginWorkflow
Function Authenticate(ByVal user As String, ByVal pswd As String) As Boolean
End Interfacepublic interface ILoginWorkflow {
bool Authenticate(string user, string pswd);
}You must also bind the WebServiceReceive activity to one of the methods in that interface.
The WebServiceReponse activity comes at the end of the workflow and passes information back to the calling application. You must set the ReceiveActivityId property of this activity to the ID of the WebServiceReceive activity. You must also generate event handlers for the WebServiceReceive activity. Do this by right-clicking it, and then click Generate Handlers.
In Visual Studio 2005, right-click the workflow project, and then click Publish as Web Service. The Workflow Designer creates a Web service project with a Web.config file, an .asmx endpoint file, and a .dll file that contains the compiled workflow. You must copy these files to an Internet Information Services (IIS) 6.0 virtual directory.
Include the WebServiceReceive activity in your workflow.
浙公网安备 33010602011771号