Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Roles, Role-Links and Parties Revisited Using a Simple MailOrder Processing System

4.00/5 (2 votes)
6 Dec 2011CPOL3 min read 27.1K   309  
A simple mail order company case solved using Roles and Parties

Introduction

I have noticed that BizTalk role-links are not used by developers due to the lack of understanding about it. This article attempts to allay the fears of using role-links in BizTalk. Role-links are not BAS and need not use BAS.

Case Study: A Mail-Order Company

Scenario

A mail order company sends several packages to different destinations. The mail order company uses several shippers for this purpose. For example FEDEX, UPS and USPS. Every shipper covers certain destination Zip codes due to proximity of the airports or special delivery processes. The Shippers destination zip code coverages keep changing during different seasons (spring/summer/fall/winter).

MailOrderCompanyCase.PNG

Conditions

The zip codes covered by the various shippers keep changing due to various conditions.

Problem to be Solved!

  1. Design a system where the Zipcode assigned to shippers can be easily changed without storing the specific shippers information.
  2. Adding a new shipper can be done easily.
  3. Adding a new delivery zipcode to an existing shipper.

What is a Role?

A Role in BizTalk parlance comprises of a port-type using which all the messages are sent out from an orchestration. Using one role, several parties can be attached to it. In the case under consideration, we have a Shipper role and several parties (FEDEX, UPS and USPS) attached to it.

Role.PNG

What is a Role-Link?

A role-link can be used to abstract a business process from an actual execution/delivery system. For example in the mail order system, the goal is to send a package to a customer, by hiring an intermediary, a shipper. Every shipper requires data to be sent in a certain format.

RoleLinks.PNG

What is a Party?

A Party is an entity or a business or an enterprise outside the boundary of BizTalk to which the data is transmitted. One must enlist a role-link with a party in order for it to work.

PartiesAndBP.PNG

Binding Party to a Role

When several Parties are bound to a Role, as in our case, the ZipCode field is compared in every party and the message is transmitted to the one which matches it.

BindPartyToRole.PNG

Understanding the ShipOrders Orchestration

The ShipOrders orchestration uses a Role-Link (ZipCodeShipper) and a Role (Shipper) to send the package ZipCode information to various Parties attached to its Role.

RoleLinkOrchestration.PNG
C#
ZipCodeShipper(Microsoft.XLANGs.BaseTypes.DestinationParty) = 
    new Microsoft.XLANGs.BaseTypes.Party(MailOrderMsg.Body.ShippingZipCode, "ZipCode");

The party takes two parameters, the first is the name and the other is the qualifier. Notice how the destination party is set, by providing the zipcode value and the qualifier "ZipCode".

The Input XML

NOTE that the ShippingZipCode is the promoted field.

InputFile.PNG

Development Notes

Error: MailOrderProcessing: Destination party not found while attempting to send message 'MailOrderMsg' to (94553, ZipCode).

Resolution: This could happen when the shipper role does NOT have this Zipcode in its delivery list. One of the enlisted parties must have this ZipCode added, this could fix the issue.

Downloadable Code

The BizTalk Party configuration is left as an exercise to the developer.

References

Role Links Blog References

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)