다음을 통해 공유


Implementing a workflow service for inbound LOB operations

Consider the following scenario – I want to write a workflow that gets instantiated when certain changes happen in LOB (say a new row is added to a table) and then does some processing with the altered data. In the current release of Microsoft BizTalk Server, Add Adapter Service Reference (AASR) generates LOB activities only for outbound operations. For inbound operations (polling, notification, etc), AASR only generates the contract and configuration information along with a dummy service implementation. This blog explains how to create such a workflow service and host it in IIS.

I will use a Typed Polling scenario for WCF SQL adapter to illustrate the steps involved for a one-way operation.

Generate service - Create a new “WCF Workflow Service Application”. Run AASR and select the appropriate inbound operation. You can delete the dummy service implementation since that’s no longer required. Let’s assume the generated contract looks like

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="https://schemas.microsoft.com/Sql/2008/05/", ConfigurationName="TypedPolling_Foo")]
public interface TypedPolling_Foo {
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="TypedPolling")]
void TypedPolling(TypedPolling request);
}

Configure the activities - Since this operation is one-way, we will delete the “SendResponse” activity and also remove the co-relation handle from the “Receive” activity (in the properties for the “Receive” activity, select CorrelationInitializers and delete the handle) and optionally from the “Variables” as well. Apply the following configuration to the activity (obtained from the above contract)

  • OperationName – TypedPolling
  • ServiceContractName – {https://schemas.microsoft.com/Sql/2008/05/}TypedPolling_Foo
  • Action – TypedPolling
  • Check CanCreateInstance

 

 

  • Content – Select “Message"
    • Message data – create a variable of type TypedPolling and specify that
    • Message type – TypedPolling

 

 

 

If the operation is two-way, i.e. needs to return a response, SAP RFC call for example, there are some differences. You shouldn’t remove the “SendResponse” activity and the correlation handle. The configuration of the “Receive” part stays the same as described above. For the “SendResponse” part, apply the following configuration.

  • Action – Set this to the ReplyAction in the OperationContractAttribute.
  • Content – Select “Message” and set the “Message type” to the return type and “Message data” to a variable of that type

 

 

Process the input - The workflow can now use the variable (Message data) to get the contents of the poll and do whatever processing it needs to do with that data

Update the config - Modify the “service” name in the configuration file to the name of the service, as specified in the xamlx file.

    <system.serviceModel>

<services>
<service name="Service1">
<endpoint address="mssql://localhost//mytestdb?InboundId=Foo" …

Deploy the service - At this point the service is ready to be hosted.  You can use VS 2010 to deploy it to IIS. From the project properties --> Web, select the “Use Local IIS Web Server”, specify a URL, create a virtual directory and then build the project. However, since the service endpoint is using a custom binding which IIS does not understand, we will need to “Auto-Start” it. This is a new feature in IIS 7.5 and is explained here. While the blog explains it in the context of Service Bus Endpoints, it applies to this scenario as well.

 

Sandeep Prabhu,
BizTalk Server Team

Comments

  • Anonymous
    March 16, 2011
    Hi, nice work!Ill tried to get this running but it will not work.Any chance to get an sample app?regardskajo
  • Anonymous
    June 01, 2011
    Hi,Is the SDK going to support the creation of Inbound Acitivities in the future?Thanks