Web Services
  Home arrow Web Services arrow Fault Handling with Web Services
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WEB SERVICES

Fault Handling with Web Services
By: Sams Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 4
    2006-08-31

    Table of Contents:
  • Fault Handling with Web Services
  • Fault Handling
  • Fault Handler Example
  • Event Handling

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Fault Handling with Web Services


    (Page 1 of 4 )

    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).

    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:

    <sequence>
    <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=
    "bpws:getVariableData('checkLocalStockResponse',
    '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:

    <switch>
    <case condition="bpws:getVariableData(
    'poSubmissionResponse','invoice','/totalCost')<100">
    <!-- add shipping and handling fee -->
    ...
    </case>
    <case condition="bpws:getVariableData(
    'poSubmissionResponse','invoice','/totalCost')<800">
    <!-- do nothing -->
    <empty/>
    </case>
    <otherwise>
    <!-- subtract rebate for large orders -->
    ...
    </otherwise>
    </switch>

    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 -->
    </scope>

    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.

    More Web Services Articles
    More By Sams Publishing


       · This article is an excerpt from the book "Building Web Services with Java: Making...
     

    Buy this book now. This article 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). Check it out today at your favorite bookstore. Buy this book now.

    WEB SERVICES ARTICLES

    - 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
    - Orchestrating Web Services
    - Notifications and Resources in the WS-Resour...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek