Home arrow Web Services arrow Fault Handling with Web Services

Fault Handling with Web Services

Last week, we looked at the assign and other basic activities, and studied flow. This week, we'll be examining more sturctured activities, and fault handling. This article, the fifth in a six-part series, is excerpted from chapter 12 of Building Web Services with Java: Making sense of XML, SOAP, WSDL, and UDDI, written by Steve Graham et al. (Sams; ISBN: 0672326418).

Author Info:
By: Sams Publishing
Rating: 4 stars4 stars4 stars4 stars4 stars / 20
August 31, 2006
  1. · Fault Handling with Web Services
  2. · Fault Handling
  3. · Fault Handler Example
  4. · Event Handling

print this article

Fault Handling with Web Services
(Page 1 of 4 )

More Structured Activities: sequence, while, switch, scope

Besides the pick and flow activities, BPEL provides several additional types of structured activities. The sequence activity lets you specify that activities are to be executed in the order in which they are provided. The following snippet shows three activities from the purchase order process. They always run in the specified order; the purchase order request is received first, then processed, and finally answered:

<receive partnerLink="buyer"
portType="pos:poSubmissionPortType" operation="doSubmission"
createInstance="yes" variable="poSubmissionRequest"> ... </receive> <flow> ... </flow> <reply partnerLink="buyer"
portType="pos:poSubmissionPortType" operation="doSubmission" variable="poSubmissionResponse"> ... </reply> </sequence>

The while activity has a nested activity that is repeatedly executed as long as a specified Boolean condition is evaluated as true. The condition is provided as an XPath expression. In our example, such an activity is used at the point where the local stock needs to be replenished. Additional goods are ordered from the supplier as long as the purchase order can't be processed from the local stock:

<while condition=
'available')= false"> <!-- Replenish local stock ... --> </while>

The switch activity can be compared to similar constructs in programming languages: for example, the switch statement in Java with its case and default branches. It lets you select exactly one branch out of a given set of choices. For each choice, provided as a list of case elements with a Boolean condition, a nested activity must be specified. The activity on the first branch (in the order of specification) whose condition

evaluates to true is executed. If an otherwise element is provided, then its nested activity is executed if none of the case conditions evaluate to true:

<case condition="bpws:getVariableData(
<!-- add shipping and handling fee -->
<case condition="bpws:getVariableData(
<!-- do nothing -->
<!-- subtract rebate for large orders -->

The scope activity is used to specify visibility boundaries. Scopes have the same structure as the overall process, except for partnerLinks and partners, which can only be declared globally in the process, and a compensation handler, which can only be declared in scopes:

<scope ...>
<!-- Variable definitions -->
<!-- Correlation set definitions -->
<!-- Fault handler definitions -->
<!-- Compensation handler definitions -->
<!-- Event handler definitions -->
<!-- Body of scope: activity -->

Definitions at the scope level apply to all nested activities. The only mandatory element is the nested activity, which may be a structured activity as well. Variables and correlation sets declared in a scope are only visible to activities nested within that scope.

Fault handlers, compensation handlers, and event handlers can be declared in a scope as well. Let's now examine these handlers in detail.

blog comments powered by Disqus

- Dealing with Loose Coupling in a Service-Ori...
- Loose Coupling in a Service-Oriented Archite...
- Safety, Idempotence, and the Resource-Orient...
- The Resource-Oriented Architecture in Action
- Features of the Resource-Oriented Architectu...
- The Resource-Oriented Architecture
- Getting Started with Flex
- Automated Billing and Faxing for the Web
- An Introduction to Web Services
- The Foundations of Web Services: From Novice...
- Web Services Reengineering: Finishing Touches
- Fault Handling with Web Services
- Flow and Web Services
- Process Lifecycles and Web Services
- Business Processes and Web Services

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials