Skip to main content

Policy lookup with WebSphere Service Registry and Repository using the policy resolution primitive in WebSphere ESB V6.2

Sobha R. Warrier (sobharwa@in.ibm.com), SOA Architect, SOA Technology Practice, IBM
Sobha R. Warrier is an SOA Architect on the WebSphere B2B team at the IBM India Software Lab in Bangalore. You can contact Sobha at sobharwa@in.ibm.com

Summary:  WebSphere Service Registry and Repository enables you to load, change, and retrieve policy documents. Policy lookup uses a new policy resolution primitive in WebSphere ESB V6.2, and it retrieves policy for a particular service or operation based on the gate conditions built using values from the message, and associates a specific policy with a runtime instance. This article shows you how to use the policy resolution primitive for policy lookup from WebSphere Service Registry and Repository, and how to control message content and mediation flow using the policy.

Date:  24 Jun 2009
Level:  Intermediate
Activity:  1767 views

Introduction

IBM® WebSphere® Enterprise Service Bus (hereafter called WebSphere ESB) enables loosely coupled connectivity between service requesters and service providers in service-oriented solutions. Loose coupling creates a clean separation of concerns between solution components, enabling flexibility and agility in both business processes and IT systems.

This article shows you how to implement mediation policies in WebSphere ESB that retrieve policy information to make runtime decisions from WebSphere Service Registry and Repository (hereafter called Service Registry). In order to control service requests using mediation policies, you need to have suitable Service Component Architecture (SCA) modules and mediation policy documents in Service Registry.

Mediation policy definitions in Service Registry

Policies specify the requirements that must be met so that a service can be consumed by a client. WS-Policy standard provides a simple language for describing policies in XML. Each policy consists of one or more policy assertions, which do not really follow any predefined format, other than the fact that they use XML. Service Registry supports the loading, retrieving, and editing of policies. The implementation of service policy management in Service Registry is based on the following standards:

Web Services Policy 1.5 -- Framework (WS-Policy)
Defines an abstract model and an XML-based expression grammar for declaring policies.
Web Services Policy 1.2 -- Attachment (WS-PolicyAttachment)
Defines mechanisms for associating policies with the subjects to which they apply.

Credit score scenario

A company provides a credit score service to its customers and charges them based on certain parameters, such as whether customer age is under 18 and whether it is an online application. The pricing policies are stored in the service registry. Here is the assembly diagram for the credit score service:


Figure 1. SCA assembly module
Figure 1

This article will show how you to define the pricing policies in Service Registry and how to use them in the mediation flow through the following steps:

  1. Create a mediation module in WebSphere ESB with the policy resolution primitive.
  2. Load an SCA module and the associated mediation policies in Service Registry.
  3. Create a mediation policy for the SCA module.
  4. Attach a mediation policy to the SCA module.
  5. Create a conditional mediation policy.

Creating a mediation module in WebSphere ESB with the policy resolution primitive


Figure 2. Mediation module
Figure 2

Figure 2 shows the mediation module for the credit score service. The pricing policy primitive retrieves the appropriate pricing policy from Service Registry based on the request parameters shown in Figure 3 below, and the assertion amount is obtained from the policy and is set in the dynamicProperty context field, as shown in Figure 4:


Figure 3. Policy resolution primitive
Figure 3


Figure 4. Dynamic property context in SMO
Figure 4

Any property promoted from a primitive in the top-level request, response, or fault flow is a dynamic property, which can be overridden at runtime using a mediation policy. In Figure 5, the promoted property amount is overridden at runtime and set using the values of the corresponding assertion field:


Figure 5. Promoted properties
Figure 5

Depending on the policy chosen at runtime from Service Registry, the amount will be different depending on the requestor age and channel. The Policy Details Table shows the amounts that will be set in the dynamicProperty context field:


Policy details
Policy GroupCondition for the policyAssertion Field
Group Acustomer age < 18 and channel = webAmount = 100
Group B customer age > 18 and channel = webAmount = 200
Group Ccustomer age < 18 and channel = otherAmount = 200
Group Dcustomer age > 18 and channel = otherAmount = 500

Loading an SCA module and associated mediation policies in Service Registry

Export SCA module as an EAR file to the local file system. When the SCA module is exported, WebSphere Integration Developer generates a default mediation policy for each property group in your SCA module. The default mediation policies represent the values given to all dynamic properties at development time. Although WebSphere Integration Developer generates default mediation policies, it does not attach them to the SCA module. After you load the EAR file containing the SCA module, Service Registry creates an SCA module document and also loads any system-generated mediation policies:


Figure 6. Credit module in Service Registry
Figure 6

Creating a mediation policy for an SCA module

  1. In the navigation pane of the Service Registry Web UI, click Service Documents => Policy Documents => New.
  2. Select WS Policy Framework 1.5 and click Next.
  3. Enter the name of the mediation policy and description (optional):

    Figure 7. Create mediation policy
    Figure 7


  4. Click Policy.
  5. Click Add Property. The Optional Properties Policy Identifier is selected.
  6. Click Add and enter a unique identifier.
  7. Click Select Policy Domain. The policy domains are listed and the relevant mediation domain of Price is selected:

    Figure 8. Selecting the policy domain
    Figure 8


  8. Click Apply.
  9. Click Select Policy Type. The policy type relates to the property group that you defined in WebSphere Integration Developer.
  10. Click Select.
  11. Click Add Assertion.
  12. Select a mediation policy assertion for a property that you want to override. Each assertion relates to a dynamic property in a particular property group, so you can select an assertion for any dynamic property in a particular property group. Choose the Assertion amount, as shown in Figure 9:

    Figure 9. Policy Assertion field
    Figure 9


  13. Click Add and enter a value for the assertion.
  14. Click Publish.

The mediation policies for GroupA, GroupB, GroupC, and GroupD are defined in the Service Registry, as shown in Figure 10:


Figure 10. Pricing policies for different customer groups
Figure 10

Attaching a mediation policy to an SCA module

When an SCA integration module is loaded into Service Registry, any default mediation policies are loaded along with the SCA module. The default mediation policies are not attached to the SCA module, so use the following steps to attach the policy:

  1. In the navigation pane of the Service Registry Web UI, click Service Documents => SCA Integration Modules => SCA Module Documents. The SCA Module Documents page opens.
  2. Select CreditModule in the SCA module document. The details of the SCA module document are displayed.
  3. Click Relationships => Modules => CreditModule. The module details are displayed.
  4. Click Policy. The mediation policy details are displayed.
  5. Click Edit Policy Attachments.
  6. Click Attach Policy. The Add Policy Attachment information is displayed.
  7. Click Search.
  8. Select a mediation policy that you want to attach to your SCA module, such as urn:GroupA.
  9. Click Apply and then click Finish.

Repeat the steps above for the other policies urn:GroupB, urn:GroupC, and urn:GroupD. Four different policies are linked to the CreditModule, as shown in Figure 11:


Figure 11. Pricing policies attached to CreditModule
Figure 11

Creating a conditional mediation policy

Gate conditions built using values from the message are used to associate with the specific policy, out of the four pricing policies attached to the CreditModule in Service Registry. The assertion in the policy in turn will set the correct amount in the dynamicProperty context field. To create the gate condition for each policy:

  1. In the navigation pane of the Service Registry Web UI, click Service Documents => Policy Documents => Documents with Policy Attachments.
  2. To update, select one of the mediation policy attachment documents, such as CreditModule_Module_CreditModule_urn:GroupA.xml. The details of the attachment document are displayed.
  3. Under Relationships => Attachments, select the attachment CreditModule_Module_CreditModule_urn:GroupA.xml.
  4. Click Edit Properties.
  5. Click Add Property. You can now add a property name.
  6. Enter the custom property name as medGate_Condition1, which is the gate condition name. Gate condition names must start with medGate_ followed by a user-defined string.
  7. Click Add.
  8. Enter the gate condition value -- in this case < 18. The variable name age is the policy condition name in the Policy Resolution primitive, as shown in Figure 2 above.
  9. Similarly, add the name medGate_Condition2 and value of channel = web.
  10. Click Apply.

The policy is updated by adding two properties that hold the condition to select this policy. Repeat the steps above for the other policies and add the relevant medGate_Conditions. For CreditModule_Module_CreditModule_urn:GroupB.xml time, add a property medGate_Condition1 holding the values age <= 18 and channel = web.

Using the Xpath in Figure 2, the policy resolution primitive retrieves the value of age and channel from the request message and calls Service Registry. Based on the gate conditions, the specific pricing policy is chosen.

Conclusion

This article showed that mediation policies control the message content and mediation flow. WebSphere Service Registry and Repository supports loading, changing, and retrieving policy documents, which can then be used by a runtime component such as an ESB to retrieve policies for a particular service or operation based on the gate conditions built using values from the message.

Acknowledgements

The author would like to thank Muhammed Yaseen of IBM India for reviewing this article.



Download

DescriptionNameSizeDownload method
Code samplecreditMod.zip62 KB HTTP

Information about download methods


Resources

About the author

Sobha R. Warrier is an SOA Architect on the WebSphere B2B team at the IBM India Software Lab in Bangalore. You can contact Sobha at sobharwa@in.ibm.com

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=399342
ArticleTitle=Policy lookup with WebSphere Service Registry and Repository using the policy resolution primitive in WebSphere ESB V6.2
publish-date=06242009
author1-email=sobharwa@in.ibm.com
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers