Event Handlers


An event handler is a set of activities that run concurrently with the primary activity of the same scope or, outside a scope, with the primary activity of the process. We describe event handlers in Chapter 8.

 <eventHandlers>?    <onEvent partnerLink="NCName"             portType="QName"?             operation="NCName"             ( messageType="QName" | element="QName")?             variable="BPELVariableName"?             messageExchange="NCName"?>*       <correlations>?          <correlation set="NCName" initiate="yes|join|no"? />+       </correlations>       <fromParts>?          <fromPart part="NCName" toVariable="BPELVariableName" />+       </fromParts>       <scope ...>...</scope>    </onEvent>    <onAlarm>*       (       <for expressionLanguage="anyURI"?>duration-expr</for>       |       <until expressionLanguage="anyURI"?>deadline-expr</until>       )?       <repeatEvery expressionLanguage="anyURI"?>?          duration-expr       </repeatEvery>       <scope>...</scope>    </onAlarm> </eventHandlers> 

Here's an example.

 <process>    <eventHandlers>       <onEvent partnerLink="ProcessPolicyPL"                portType="ProcessPolicyPT"                operation="status"                messageType="statusRequestMsg"                variable="statusRequest">          <correlations>             <correlation initiate="no" set="quoteID" />          </correlations>          <sequence name="provideCallerTheCurrentStatus">             <assign name="Assign" validate="no">                <copy>                   <from variable="currentStatus" />                   <to   variable="statResponse"                         part="statResult" />                </copy>             </assign>             <reply name="StatusReply"                    partnerLink="ProcessPolicyPL"                    portType="ProcessPolicyPT"                    operation="status"                    variable="statusResponse" />          </sequence>       </onEvent>       <!- the event fires at 9AM Eastern Standard Time             on 24 December 2010 ->       <onAlarm>          <until>'2010-12-24T09:00-05:00'</until>          <scope>             <invoke .../>          </scope>       </onAlarm>       <!- the event fires every 3 hours ->       <onAlarm>          <repeatEvery>'PT3H'</repeatEvery>          <scope>             <invoke .../>          </scope>       </onAlarm>       <!- the event fires after 5 minutes             and every day thereafter ->       <onAlarm>          <for>'PT5M'</for>          <repeatEvery>'P1D'</repeatEvery>          <scope>             <invoke .../>          </scope>       </onAlarm>    </eventHandlers> </process> 

Fault Handlers

A fault handler responds to a runtime error. We describe fault handling in Chapter 7.

 <faultHandlers>?    <!- Note: There must be at least one faultHandler ->    <catch faultName="QName"?       faultVariable="BPELVariableName"?       ( faultMessageType="QName" | faultElement="QName")? >*       activity    </catch>    <catchAll>?       activity    </catchAll> </faultHandlers> 

Here's an example.

 <faultHandlers>    <catch faultName=" cannotCompleteRequest"       faultVariable="DMVFault"       faultMessageType="DMVFaultType">       <reply partnerLink="dmvPL"       portType ="DMVPT"       operation="sendDMVRecord"       variable="DMVFault"       faultName="cannotCompleteRequest" />    </catch> </faultHandlers> 

Imports

An import element includes a WSDL or XML Schema definition in a BPEL process.

 <import namespace="anyURI"?    location="anyURI"?    importType="anyURI" />* 

The namespace attribute specifies the namespace of interest; the location attribute indicates where the file resides; and the importType attribute specifies a URI that tells the technology type and version.

Here are two commonplace values for importType:

  • For WSDL 1.1: "http://schemas.xmlsoap.org/wsdl/"

  • For XSD (XML 1.0): "http://www.w3.org/2001/XMLSchema"

Here's an example.

 <import namespace="http://www.dmv.org/"          location="dmv/MotorVehicleRecordsService"          importType="http://schemas.xmlsoap.org/wsdl/" /> 

Message Exchanges

Message exchanges help you to pair a reply activity with an inbound message activity in unusual cases, as described in Chapter 7.

 <messageExchanges>?    <messageExchange name="NCName" />+ </messageExchanges> 

Here's an example.

 <messageExchanges>    <messageExchange name="applicant" />    <messageExchange name="spouse" /> </messageExchanges> 

Partner Links

Each partner link identifies the relationship between the BPEL process and a partner service, including the role played by one, the other, or both. We describe partner links in Chapter 7, starting with a review of partner link types.

 <partnerLinks>?    <!- Note: At least one role must be specified. ->    <partnerLink name="NCName"       partnerLinkType="QName"       myRole="NCName"?       partnerRole="NCName"?       initializePartnerRole="yes|no"?>+    </partnerLink> </partnerLinks> 

Here's an example.

 <partnerLinks>    <partnerLink name="ProcessQuotePL"                 partnerLinkType="ProcessQuotePLT"                 myRole="ProcessQuoteRole" />    <partnerLink name="riskAnalysisPL"                 partnerLinkType="PartnerPLT"                 partnerRole="evaluateRisk" />    <partnerLink name="QuoteManagementPL"                 partnerLinkType="PartnerLinkPLT"                 partnerRole="storeQuote" /> </partnerLinks> 

Process

The process element is the topmost definition of a BPEL process. We describe the overall structure in Chapter 7.

 <process name="NCName" targetNamespace="anyURI"          queryLanguage="anyURI"?          expressionLanguage="anyURI"?          suppressJoinFailure="yes|no"?          exitOnStandardFault="yes|no"?          xmlns=          "http://docs.oasis-open.org/wsbpel/2.0/process/executable"> </process> 

Here's an example.

 <process name="ProcessQuote">    <!- omitted namespaces, as well as         imports of WSDL and XSD definitions ->    <partnerLinks>       <partnerLink name="ProcessQuotePL"          partnerLinkType="ProcessQuotePLT" myRole="ProcessQuoteRole" />       <partnerLink name="QuoteManagementPL"          partnerLinkType="PartnerLinkPLT" partnerRole="partnerRole" />    </partnerLinks>    <variables>       <variable name="quoteRequest"                 messageType="placeQuoteRequestMsg" />       <variable name="highlightQuote"                 messageType="placeQuoteResponseMsg" />       <variable name="buildQuoteReq"                 messageType="buildQuoteRequestMsg" />       <variable name="newHighlightQuote"                 messageType="buildQuoteResponseMsg" />    </variables>    <sequence>       <receive name="processQuoteRequest" createInstance="yes"                operation="placeQuote" partnerLink="ProcessQuotePL"                portType="ProcessQuotePT" variable="quoteRequest" />       <assign name="AssignQuoteReq">          <copy>             <from variable="quoteRequest" part="placeQuoteParameters">                <query>/quoteInformation</query>             </from>             <to variable="buildQuoteReq" part="buildQuoteParameters">                <query>/customerQuoteInfo</query>             </to>          </copy>       </assign>       <invoke name="CalculateQuote" inputVariable="buildQuoteReq"                operation="buildQuote" outputVariable="newHighlightQuote"                partnerLink="QuoteManagement" portType="QuoteManagement" />       <assign name="AssignQuoteRes">          <copy>             <from variable="newHighlightQuote" part="buildQuoteResult">                 <query>/quote</query>             </from>             <to variable="highlightQuote" part="placeQuoteResult" >                <query>/quote</query>             </to>          </copy>       </assign>       <reply name="processQuoteResponse"              operation="placeQuote" partnerLink="ProcessQuotePL"              portType="ProcessQuotePT" variable="highlightQuote" />    </sequence> </process> 

Termination Handlers

A termination handler is an activity (usually a structured activity) that is issued when a running scope is being forced to terminate. We describe termination in Chapter 7.

 <compensationHandler>    activity </compensationHandler> 

The default termination handler in each scope is as follows.

 <terminationHandler>    <compensate/> </terminationHandler> 

The effect of the default is to run the compensation handlers of all nested scopes.

Variables

Variables are named data areas. As described in Chapter 7, each is based on a WSDL message definition (called a message type) or on an XML Schema element or type. To assign an initial value, include a from-spec, which is described later.

 <variables>    <variable name="BPELVariableName"       messageType="QName"?       type="QName"?       element="QName"?>+       from-spec?    </variable> </variables> 

The from-spec is any of the next from elements, which are also the source for assign activities.

 <from variable="BPELVariableName" part="NCName"?>    <query queryLanguage="anyURI"?>?       queryContent    </query> </from> | <from partnerLink="NCName" endpointReference="myRole|partnerRole" /> | <from variable="BPELVariableName" property="QName" /> | <from expressionLanguage="anyURI"?>expression</from> | <from><literal>literal value</literal></from> 

Here are examples.

 <variables>    <variable name="quoteRequest"               messageType="placeQuoteRequestMsg" />    <variable name="theAddress" type="xsd:string">       <from variable="quoteRequest"             property="emailAddr" >    </variable>    <variable name="theAddress02" type="xsd:string">       <from variable="quoteRequest"             part="placeQuoteParameters" >          <query>             /quoteInformation/applicantEmailAddr          </query>       </from>    </variable>    <variable name="currentStatus"type="xsd:string"       <from>          <literal>approved</literal>       </from>    </variable>    <variable name="myRequestID"element="placeQuote"/> </variables> 




SOA for the Business Developer. Concepts, BPEL, and SCA
SOA for the Business Developer: Concepts, BPEL, and SCA (Business Developers series)
ISBN: 1583470654
EAN: 2147483647
Year: 2004
Pages: 157
Authors: Ben Margolis

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net