Share via


Walkthrough: BizTalk Orchestration using Schema as WCF Service (Asynchronous / Synchronous)

Introduction

I was reading 8 Tips And Tricks For Better BizTalk Programming by Marty Wasznicky and Scott Zimmerman. As per section 4 Never Expose Your Internal Schemas Directly in WSDL. This was quite interesting as I was aware of both the method (Publish Orchestration as WCF Service, Publish Schema as WCF Service). In my previous projects I always implemented Orchestration as WCF service methodology so I thought to do the similar scenario as Schema as WCF service. While looking  material online I found Synchronous To Asynchronous Flows Without An Orchestration and Messaging-only request-response correlation. As per the article I tried to implement my Orchestration as Asynchronous as well as Synchronous mode.  I had come up with lot of issue while implementing this scenario so thought of creating this walktrhough.

Scenario

We are going to publish schema as wcf service. We are going to create Orchestration which will subscribe message directly from MessageBox. It will process the message and publish message back to MessageBox. From Message box this message will be picked by Solicit Request-Response port and message is routed back to client.

Solution

Creating BizTalk Solution

  • Create a new BizTalk project “BizTalkOrchestrationService”. Create two schemas in this project.

  • Build this project and deploy it.

Publish Schema as WCF service

Use How to Use the BizTalk WCF Service Publishing Wizard to Publish Schemas as WCF Services to publish above schema as WCF Service. Once publishing wizard is completed open BizTalk server group hub page. Verify if receive port was created.

The above process is used to publish schema as web service. Now we have to create a orchestration which will fetch message directly from BizTalk Message based on bts.messagetype. It will process the message and publish it back to MessageBox so that Solicit Request-Response port will route it back to calling application.

Create map “Transform.btm” in BizTalk project “BizTalkOrchestrationService”

  • Source schema -> BizTalkOrchestrationService.EmployeeDetail 
  • Destination schema -> BizTalkOrchestrationService.EmployeeName 

Creating Synchronous Orchestration  

  • In the project created in step 1, add a new orchestration “EmployeeOrchestrationSync.odx”.
  • Design the Orchestration as per below diagram

  • Create two messages in orchestration view
    • MessageEmployeeIn -> BizTalkOrchestrationService.EmployeeDetail (MessageType)
    • MessageEmployeeOut -> BizTalkOrchestrationService.EmployeeName (MessageType)
  • Configure Orchestration Shape
    • ReceiveEmployeeDetail -> Message (MessageEmployeeIn), Activate (True), Filter (BTS.MessageType == "http://BizTalkOrchestrationService.EmployeeDetail#Employee")) *Verify this in your solution.
    • SendEmployeeName -> Message (MessageEmployeeOut)
    • ConstructMessage -> MessageConstructed (MessageEmployeeOut)
    • Transform -> MapName (BizTalkOrchestrationService.Transform), InputMessage (MessageEmployeeIn), OutputMessage (MessageEmployeeOut)
    • PortEmployee -> PortType (PortTypeEmployee, Request-Response, PortDirection(I will be receiving request and sending response), PortBinding (Direct, Routing between port will be defined……)  
  • Deploy this solution”. Once deployed configure binding of “EmployeeOrchestrationSync”. Start application and do the testing.
  • To test used WCF test client to invoke WCF service.

Creating Asynchronous Orchestration

  • In the project created in step 1, add a new orchestration “EmployeeOrchestrationAsync.odx”.
  • Design the Orchestration as per below diagram

  • Create two messages in orchestration view
    • MessageEmployeeIn -> BizTalkOrchestrationService.EmployeeDetail (MessageType)
    • MessageEmployeeOut -> BizTalkOrchestrationService.EmployeeName (MessageType)
  • Create Correlation in Orchestration
    • CorrelationType -> CorrelationTypeWcfSchema, (Correlation Properties -> BTS.CorrelationToken,BTS.EpmRRCorrelationToken,BTS.IsRequestResponse,BTS.ReqRespTransmitPipelineID,BTS.RouteDirectToTP )
    • Correlation Set -> CorrelationWcfSchema (Correlation Type -> BizTalkOrchestrationService.CorrelationTypeWcfSchema )
  • Configure Orchestration Shape
    • ReceiveEmployeeDetail -> Message (MessageEmployeeIn), Activate (True), Filter (BTS.MessageType == "http://BizTalkOrchestrationService.EmployeeDetail#Employee")) *Verify this in your solution.  
    • SendEmployeeName -> Message (MessageEmployeeOut), Initialize Correlation(CorrelationWcfSchema )  
    • ConstructMessage -> MessageConstructed (MessageEmployeeOut)  
    • Transform -> MapName (BizTalkOrchestrationService.Transform), InputMessage (MessageEmployeeIn), OutputMessage (MessageEmployeeOut)  
    • MessageAssignmentPromotedProperty 
      • MessageEmployeeOut(*)=MessageEmployeeIn(*);
      • MessageEmployeeOut(BTS.RouteDirectToTP) = true;
      • MessageEmployeeOut(BTS.IsRequestResponse) = true;
    • PortRcvEmployee-> PortType (PortTypeRcvEmployee, One way, PortDirection(I will be receiving message), PortBinding (Direct, Routing between port will be defined……)  
    • PortSndEmployee-> PortType (PortTypeSndEmployee, One way, PortDirection(I will be sending message), PortBinding (Direct, Routing between port will be defined……)  
  • Deploy this solution”. Once deployed configure binding of “EmployeeOrchestrationSync”. Start application and do the testing.(Unenlist other orchestration)
  • To test used WCF test client to invoke WCF service.

See Also

Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.