Workflow .NET Assemblies
This section describes how to use Workflow .NET Assemblies to enable interaction between workflow rules and external systems.
In This Topic
Describes how to set up a workflow .NET assembly.
Describes the configuration file needed for workflow .NET assemblies.
Shows the schema for the configuration file.
Shows sample code and the corresponding configuration file.
Figure 1 – Overview of Workflow .NET Assemblies
You can call a Web service or any .NET assembly from workflow. This brings a great deal of extensibility to your workflow solution. Web services calls are treated as a special kind of .NET assembly calls. To call a Web service, you first provide a proxy assembly. Then you can reference this assembly in the workflow rule editor. Any assembly can be used, there is no need to sub-class or implement a particular interface in your assembly.
Support for Web Services
Web Services can be called from .NET assemblies. To do this you follow these steps:
- Create a proxy server or reference to the CrmService Web service. See Setting up the Web Services.
- Generate a library that references or contains the Web service classes.
- Move the assembly generated to this directory:
<<installation drive>>\Program Files\Microsoft CRM\Server\bin\assembly\.
- Stop the Workflow Service.
- Update the configuration file:
<<installation drive>>\Program Files\Microsoft CRM\Server\bin\assembly\Workflow.config
- Reset Internet Information Services (IIS): Click Start, Run, type iisreset and press Enter.
- Restart the Workflow Service.
Note To interact with non-Microsoft Web Services use the Web Services Description Language Tool (Wsdl.exe) to generate a C# client proxy class.
Typically you want your assembly code to run under the context of the user who triggered the workflow. The following code demonstrates how to do this. Alternatively, you can pass the caller information as a parameter to the method. For more information on this technique, see Using the Caller Parameter Type.
The following code can be used in your workflow assembly code to impersonate the logged on user.
[C#] CrmService service = new CrmService(); service.Credentials = System.Net.CredentialCache.DefaultCredentials; // Get the current user ID. WhoAmIRequest userRequest = new WhoAmIRequest(); WhoAmIResponse userResp = (WhoAmIResponse) service.Execute(userRequest); service.CallerIdValue.CallerGuid = userResp.UserId;
For more information, see Security and Impersonation.
Support for Unsigned Assemblies
By default, the workflow service will only load signed assemblies. To load an unsigned assembly, you need to set the attribute allowunsignedassemblies to "true" in the configuration file as shown in the example below.
<workflow.config xmlns="http://microsoft.com/mscrm/workflow/" allowunsignedassemblies="true">
© 2007 Microsoft Corporation. All rights reserved.