Friday, May 6, 2011

BizTalk Role Links explained

BizTalk Role Links explained

- I like to keep these links and explanation handy (copied from other blogs into mine) at least that way I know where to find correct information at last moment without worrying someone's blog is no more available.  - Hemant

For those of you who would like to know what role links are and how you can use them in everyday life, I have a very simple customer request, and an even simpler prototype to demonstrate how to implement role links.
My situation is that I process EDI (HIPAA) files, and there is a standard map that translates the file to a flat file structure. However, the output needs to go into a client specific folder for the existing process to start.
Looking at the source of all truth and knowledge here:
A role is a collection of port types that either uses a service or implements a service. A role defines how parties interact with orchestrations. For example, an orchestration might use the role of Shipper. The Shipper has one or two parties associated with it. When the orchestration decides which shipping company to use to ship an item, it compares the prices of the parties in the Shipper role.
With my limited knowledge of Role Links, I thought that this might be a way to have one orchestration tied to an variable list of send ports. I figured that if I was a Shipper, I want to decide which shipping company (in my case two different folders) and then send it off to them.
After looking at this site and this site I was still very lost as to how to implement it. So I started playing around, and decided on a very simple prototype:
  • Receive a file
  • Interrogate the contents of the file for who the sender is
  • Set the Role Link
  • Send it out with some type of indicator so I know which sender it was
Pretty easy I thought, and actually implementing it was not too hard.
  1. I created an empty BizTalk project
  2. I constructed a sample file and since I am lazy, I made Data a distinguished field.
  3. I then created an orchestration that had a Port Type defined from the schema I just created.
  4. I then created a Recieve Port using the FilePortType.
  5. I then created a new Role Link Type and named it SendingRoleLinkType
  6. When you expand the new link type, and right click on Role_1, it asks you to Add Port Type
  7. So of course I do, and I choose the existing port type, in the Port Type Wizard
  8. I also rename the Role_1 to Sender
  9. I then created a role named Destination
  10. I am using an existing Role Link Type already defined
  11. It is the Consumer role.
  12. I created two parties and for the HIPAA accelerator, the format is EDI:\\ISASenderID:Qualifier:GSSenderID
  13. These parties are defined as Party1 (EDI:\\123456789:ZZ:123456789) and Party2 (EDI:\\987654321:ZZ:9876543521) CORRECTION: the parties should have been defined as EDI://123456789:ZZ:123456789 and EDI://987654321:ZZ:9876543521 for them to be correct

  14. I then created an expression after my receive shape to assign the role link, and here is the code:
      Destination(Microsoft.XLANGs.BaseTypes.DestinationParty)= new Microsoft.XLANGs.BaseTypes.Party(@"EDI:\\"+FileMsg.Data+"","EDI");
      Notice that in the argument 1 of Party, is the Value defined in the Party Definition, and obscurely, the OrganizationName (EDI) is the value it is looking up against. I am pulling the partner information (FileMsg.Data) out of the file (which we will see later).
  15. I then created a send shape and connected it to the Destination Port Link
  16. I deployed the project and bound the input to a default xml pipeline
  17. Now the part that exposes the power of Role Links I created a send port for trading partner 1 called, oddly enough, Party 1 Destination and set the path to E:\Role Link\Party1\%SourceFileName%.%MessageID%.xml, I did the same for trading partner 2, called Party 2 Destination and set the path to E:\Role Link\Party2\%SourceFileName%.%MessageID%.xml

  18. In the Party definition I clicked on the send port and chose the correct send port:

  19. Now we need to 'bind' the sending to the correct variable port, how you do that is if you expand the Roles, you will see the Sender Role
  20. Right click this and Enlist the Party, Enlist Party1 Then you come up with a Elist Party Properties dialog where you choose which of the ports defined in step 18 to use:

  21. After that is completed, you can enlist the orchestration and start throwing files, oh, here is a sample input to show you the data it was pulling:
Things to take away from this little tutorial:
Role Links allow you to create a lookup feature within an Orchestration to determine where to send the data, and still have all of the information available to be modified through the administration console.
The example here is for one business process, in my immediate need, for eligibility files, but later we are going to need to have a different location for claim files, while the party definition cannot change, I need to create new send ports, and then add them to the list of send ports in the party definition, and then when enlisting the role, I choose the newly created port! All VERY useful.


Thanks to : http://blog.biztalk-info.com/archive/2006/10/25/BizTalk_Role_Links_explained.aspx#ixzz1LaRzq59E

No comments:

Post a Comment

FEEDJIT Live Traffic Map