User’s Guide

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Modeling Message Flow in ALSB

In ALSB, a message flow defines the implementation of a proxy service. You can create and configure ALSB proxy services in the ALSB Console or the ALSB Plug-in for WorkSpace Studio. This section describes message flows and presents guidelines for designing them.

The following sections describe message flows in ALSB:

For instructions on creating and configuring message flows in the ALSB Console, see:

For instructions on creating and configuring message flows in the ALSB Plug-in for WorkSpace Studio, see:

 


Message Flow Components

A message flow is composed of components that define the logic for routing and manipulating messages as they flow through a proxy service. Nodes are configured to route messages through the message flow, and stages and actions contain rules for processing and transforming messages.

Most of the processing logic in a message flow is handled in pipelines. A pipeline is a named sequence of stages representing a non-branching one-way processing path. Pipelines belong to one of the following categories:

To implement the processing logic of a proxy service, request and response pipelines are paired together in pipeline pair nodes. These pipeline pair nodes can be combined with other nodes into a single-rooted tree structure to control overall flow.

Table 3-1 describes the components available for defining message flows.

Table 3-1 Message Flow Components
Component Type
Summary
Start node
Every message flow begins with a start node. All messages enter the message flow through the start node, and all response messages are returned to the client through the start node. There is nothing to configure in a start node.
Pipeline pair node
A pipeline pair node combines a single request pipeline and a single response pipeline in one top-level element. A pipeline pair node can have only one direct descendant in the message flow. During request processing, only the request pipeline is executed when ALSB processes a pipeline pair node. The execution path is reversed when ALSB processes the response pipeline.
Stage
Request pipelines, response pipelines, and error handlers can contain stages, where you configure actions to manipulate messages passing through the pipeline.
Error handler
An error handler can be attached to any node or stage, to handle potential errors at that location.
Branch node
A branch node allows processing to proceed along exactly one of several possible paths. Operational branching is supported for WSDL-based services, where the branching is based on operations defined in the WSDL. Conditional branching is supported for conditions defined in an XPath-based switch table.
Route node
A route node performs request/response communication with another service. It represents the boundary between request and response processing for the proxy service. When the route node dispatches a request message, the request processing is considered complete. When the route node receives a response message, the response processing begins. The route node supports conditional routing as well as request and response transformations.
Because a route node represents the boundary between request and response processing, it cannot have any descendants in the message flow.

Figure 3-1 shows a high level view of components in a message flow definition.

Figure 3-1 Components of Message Flow

Components of Message Flow

Building a Message Flow

The only components required in a message flow are a start node and a route node. No restrictions exist on what other components can be chained together in the message flow. You could create a single route node that contained all the logic for the flow. Or, you could link two pipeline pair nodes without a branch node in between. If you use branch nodes, each branch node could start with a different element. One branch could terminate with a route node, another could be followed by a pipeline pair, and yet another could have no descendant. (When a branch with no descendants is executed at run time, response processing begins immediately.)

However, in general, a message flow is likely to be designed in one of the following ways:

Message Execution

Table 3-2 briefly describes how messages are processed in a typical message flow.

Table 3-2 Path of a Message During a Message Flow
Message Flow Node
What Happens During Message Processing?
Request Processing
 
Start node
Request processing begins at the start node.
Pipeline pair node
Executes the request pipeline only.
Branch node
Evaluates the branch table and proceeds down the relevant branch.
Route node
Performs the route along with any request transformations.
In the message flow, regardless of whether routing takes place or not, the route node represents the transition from processing a request to processing a response. At the route node, the direction of the message flow is reversed. If a request path does not have a route node, the response processing is initiated in the reverse direction without waiting for any response.
Response Processing
Skips any branch nodes and continues with the node that preceded the branch.
Route node
Executes any response transformations.
Branch node
Skips any branch nodes and continues with the node that preceded the branch.
Pipeline pair node
Executes the response pipeline.
Start node
Sends the response back to the client.

 


Branching in Message Flows

Two kinds of branching are supported in message flows: operational branching, configured in an operational branch node, and conditional branching, configured in a conditional branch node.

Operational Branching

When message flows define WSDL-based proxy services, operation-specific processing is required. When you create an operational branch node in a message flow, you can build branching logic based on the operations defined in the WSDL.

You must use operational branching when a proxy service is based on a WSDL with multiple operations. You can consider using an operational branch node to handle messages separately for each operation.

Conditional Branching

Use conditional branching to branch based on a specified condition, for example the document type of a message.

Conditional branching is driven by a lookup table with each branch tagged with simple, unique string values, for example, QuantityEqualToOrLessThan150 and QuantityMoreThan150.

You can configure a conditional branch to branch based on the value of a variable in the message context (declared, for example, in a stage earlier in the message flow), or you can configure the condition to branch based on the results of an XPath expression defined in the branch itself.

At run time, the variable or the expression is evaluated, and the resulting value is used to determine which branch to follow. If no branch matches the value, the default branch is followed. A branch node may have several descendants in the message flow: one for each branch, including the default branch. You should always define a default branch. You should design the proxy service in such a way that the value of a lookup variable is set before reaching the branch node.

For example, consider the following case using a lookup variable. A proxy service is of type any SOAP or any XML, and you need to determine the type of the message so you can perform conditional branching. You can design a stage action to identify the message type and then design a conditional branching node later in the flow to separate processing based on the message type.

Now consider the following case using an XPath expression in the conditional branch node. You want to branch based on the quantity in an order. That quantity is passed via a variable that can be retrieved from a known location in $body. You could define the following XPath expression to retrieve the quantity:

declare namespace openuri="http://www.openuri.org/";
declare namespace com="bea.com/demo/orders/cmnCust";
./openuri:processCust/com:cmnCust/com:Order_Items/com:Item/com:Quantity

The condition (for example, <500) is then evaluated in order down the message flow against the expression. Whichever condition is satisfied first determines which branch is followed. If no branch condition is satisfied, then the default branch is followed.

You can use conditional branching to expose the routing alternatives for the message flow at the top level flow view. For example, consider a situation where you want to invoke service A or service B based on a condition known early in the message flow (for example, the message type). You could configure the conditional branching in a routing table in the route node. However, that makes the branching somewhat more difficult to follow if you are just looking at the top level of the flow. Instead, you could use a conditional branch node to expose this branching in the message flow itself and use simple route nodes as the subflows for each of the branches.

Consider your business scenario before deciding whether you configure branching in the message flow or in a stage or route node. When making your decision, remember that configuring branches in the message flow can be awkward in the design interface if a large number of branches extend from the branch node.

 


Configuring Actions in Stages and Route Nodes

Actions provide instructions for handling messages in pipeline stages, error handler stages, and route nodes. The context determines which actions are available in the ALSB Console or in the ALSB Plug-in for WorkSpace Studio, as described in the following sections:

See Also

Communication Actions

Communication actions control message flow. Table 3-3 describes the communication actions.

Table 3-3 Communication Actions
Action
Use to...
Available in
Dynamic publish
Publish a message to a service specified by an XQuery expression.
  • Pipeline stage
  • Error handler stage
  • Route node
Publish
Identify a statically specified target service for a message and to configure how the message is packaged and sent to that service.
  • Pipeline stage
  • Error handler stage
Publish table
Publish a message to zero or more statically specified services. Switch-style condition logic is used to determine at run time which services will be used for the publish.
  • Pipeline stage
  • Error handler stage
Routing options
Modify any or all of the following properties in the outbound request: URI, Quality of Service, Mode, Retry parameters, Message Priority.
  • Pipeline stage
Service callout
Configure a synchronous (blocking) callout to an ALSB-registered proxy or business service. See Constructing Service Callout Messages.
  • Pipeline stage
  • Error handler stage
Transport headers
Set the header values in messages. See Configuring Transport Headers in Message Flows.
  • Pipeline stage
  • Error handler stage

Flow Control Actions

Flow controls actions implement conditional routing, conditional looping, and error handling. You can also use them to notify the invoker of success or to skip the rest of the actions in the stage. Table 3-4 describes the flow control actions.

Table 3-4 Flow Control Actions
Action
Use to...
Available in
For each
Iterate over a sequence of values and execute a block of actions
  • Pipeline stage
  • Error handler stage
If... then...
Perform an action or set of actions conditionally, based on the Boolean result of an XQuery expression.
  • Pipeline stage
  • Route node
  • Error handler stage
Raise error
Raise an exception with a specified error code (a string) and description.
  • Pipeline stage
  • Error handler stage
Reply
Specify that an immediate reply be sent to the invoker.
The reply action can be used in the request, response or error pipeline. You can configure it to result in a reply with success or failure. In the case of reply with failure where the inbound transport is HTTP, the reply action specifies that an immediate reply is sent to the invoker.
  • Pipeline stage
  • Error handler stage
Resume
Resume message flow after an error is handled by an error handler. This action has no parameters and can only be used in error handlers.
  • Error handler stage
Skip
Specify that at run time, the execution of this stage is skipped and the processing proceeds to the next stage in the message flow. This action has no parameters and can be used in the request, response or error pipelines.
  • Pipeline stage
  • Error handler stage

Message Processing Actions

The actions in this category process the message flow. Table 3-5 describes the message processing actions.

Table 3-5 Message Processing Actions
Action
Use to...
Available in
Assign
Assign the result of an XQuery expression to a context variable.
  • Pipeline stage
  • Error handler stage
Delete
Delete a context variable or a set of nodes specified by an XPath expression.
  • Pipeline stage
  • Error handler stage
Insert
Insert the result of an XQuery expression at an identified place relative to nodes selected by an XPath expression.
  • Pipeline stage
  • Error handler stage
Java callout
Invoke a Java method, or EJB business service, from within the message flow.
  • Pipeline stage
  • Error handler stage
MFL transform
Convert message content from XML to non-XML, or vice versa, in the message pipeline. An MFL is a specialized XML document used to describe the layout of binary data. It is a BEA proprietary language used to define rules to transform formatted binary data into XML data, or vice versa.
  • Pipeline stage
  • Error handler stage
Rename
Rename elements selected by an XPath expression without modifying the contents of the element.
  • Pipeline stage
  • Error handler stage
Replace
Replace a node or the contents of a node specified by an XPath expression. The node or its contents are replaced with the value returned by an XQuery expression.
A replace action can be used to replace simple values, elements and even attributes. An XQuery expression that returns nothing is equivalent to deleting the identified nodes or making them empty, depending upon whether the action is replacing entire nodes or just node contents.
The replace action is one of a set of Update actions.
  • Pipeline stage
  • Error handler stage
Validate
Validate elements selected by an XPath expression against an XML schema element or a WSDL resource. You can validate global elements only; ALSB does not support validation against local elements.
  • Pipeline stage
  • Error handler stage

Reporting Actions

You use the actions in this category to log or report errors and generate alerts if required in a message flow within a stage. Table 3-4 describes the reporting actions.

Table 3-6 Reporting Actions
Action
Use to...
Available in
Alert
Generate alerts based on message context in a pipeline, to send to an alert destination. Unlike SLA alerts, notifications generated by the alert action are primarily intended for business purposes, or to report errors, and not for monitoring system health. Alert destination should be configured and chosen with this in mind.
If pipeline alerting is not enabled for the service or enabled at the domain level, the configured alert action is bypassed during message processing.
  • Pipeline stage
  • Error handler stage
Log
Construct a message to be logged and to define a set of attributes with which the message is logged.
  • Pipeline stage
  • Error handler stage
Report
Enable message reporting for a proxy service.
  • Pipeline stage
  • Error handler stage

Configuring Transport Headers in Message Flows

The transport header action is a communication type action, and it is available in pipeline stages and error handler stages.

Configuring Global Pass Through and Header-Specific Copy Options for Transport Headers

The following options are available when you configure a transport headers action:

Use the options in a way that best suits your scenario. Both options result in the headers in the source header set being copied to the target header set, overwriting any existing value in the target set. Note that the Pass all Headers through Pipeline option is executed before the header-specific Copy Header options. In other words, for a given transport headers action configuration, if you select Pass all Headers through Pipeline, there is no need to select the Copy Header option for given headers.

However, you can select Pass all Headers through Pipeline to copy all headers, and subsequently configure the action such that individual headers are deleted by selecting Delete Header for specific headers.

WARNING: Because transport headers are specific to the transport types, it is recommended that the pass-through (or copy) options only be used to copy headers between services of the same transport type. Passing (or copying) headers between services of different transport types can result in an error if the header being passed is not accepted by the target transport. For the same reasons, be careful when you specify a header name using the Set Header option.

Understanding How the Run Time Uses the Transport Headers Settings

As described above, you can use transport header actions to configure the values of the transport headers for outbound requests (the messages sent out by a proxy service in route, publish, or service callout actions) and inbound responses (the response messages a proxy service sends back to clients). In general, the header values can be:

The transport headers action allows you to set, delete, or pass-through the headers in $inbound or $outbound. If you set or delete these headers and then log $inbound or $outbound, you can see the effects of your changes. However, when the message is sent out, the ALSB binding layer may modify or remove some headers in $inbound or $outbound and the underlying transport may in turn, ignore some of these headers and use its own values. An important distinction is that any modifications done by the binding layer on a header are done directly to $inbound and $outbound, whereas modifications done by the transport affects only the message's wire format. For example, although you can specify a value for the outbound Content-Length header, the binding layer deletes it from $outbound when sending the message. Consequently, the modification is visible in the response path (for example, you can see the modified value if you log $outbound). If you set the User-Agent header in $outbound, the HTTP transport ignores it and use its own value—however, the value in $outbound is not changed.

Table 3-7 describes the transport headers that are ignored or overwritten at run time and other limitations that exist for specific transport headers.

Table 3-7 Limitations to Transport Header Values You Specify in Transport Header Actions
Transport
Description of Limitation...
Transport Headers Affected By Limitation...
Outbound Request
Inbound Response
HTTP
ALSB run time may overwrite these headers in the binding layer when preparing the message for dispatch. If these headers are modified, $inbound and $outbound are updated accordingly.
  • Content-Type
  • Content-Type
 
The underlying transport may ignore these headers and use different values when sending the message. Any changes done by the transport will not be reflected in $inbound or $outbound.
  • Accept
  • Content-Length
  • Connection
  • Host
  • User-Agent
  • Content-Length
  • Date
  • Transfer-Encoding
JMS
Can only be set when the request is with respect to a one-way service or a request/response service based on JMSMessageID correlation.
If sending to a request/response service based on JMSCorrelationID correlation, these headers are overwritten at run time.
  • JMSCorrelationID
  • JMSCorrelationID
 
Should be set to the message time-to-live in milliseconds. The resulting value in the message received is the sum of the time-to-live value specified by the client and the GMT at the time of the send or publish1.
  • JMSExpiration
  • JMSExpiration
 
The ALSB run time sets these headers. In other words, any specifications you make for these headers at design time are overwritten at run time.
  • JMSMessageID
  • JMSRedelivered
  • JMSTimestamp
  • JMSXDeliveryCount
  • JMSXUserID
  • JMS_IBM_PutDate2
  • JMS_IBM_PutTime 2
  • JMS_IBM_PutApplType 2
  • JMS_IBM_Encoding 2
  • JMS_IBM_Character_Set 2
  • JMSMessageID
  • JMSRedelivered
  • JMSTimestamp
  • JMSXDeliveryCount
  • JMSXUserID
  • JMS_IBM_PutDate 2
  • JMS_IBM_PutTime 2
  • JMS_IBM_PutApplType 2
  • JMS_IBM_Encoding 2
  • JMS_IBM_Character_Set 2
 
Because IBM MQ does not allow certain properties to be set by a client application, if you set these headers with respect to an IBM MQ destination, a run-time exception is raised.
  • JMSXDeliveryCount
  • JMSXUserID
  • JMSXAppID
  • JMSXDeliveryCount
  • JMSXUserID
  • JMSXAppID
 
These headers cannot be deleted when the Pass all Headers through Pipeline option is also specified.
  • JMSDeliveryMode
  • JMSExpiration
  • JMSMessageID
  • JMSRedelivered
  • JMSTimestamp
  • JMSXDeliveryCount
  • JMSDeliveryMode
  • JMSExpiration
  • JMSMessageID
  • JMSRedelivered
  • JMSTimestamp
  • JMSXDeliveryCount
  • JMSCorelationID—if the inbound message has the correlation ID set. For example, if the inbound response comes from a registered JMS business service
FTP
No limitations. In other words you can set or delete the header(s)3 for File and FTP transports and your specifications are honored by the ALSB run time.
   
File
   
E-mail
The ALSB run time sets these headers. In other words, any specifications you make for these headers at design time are overwritten at run time.
  • Content-Type
  • Content-Type
 
These headers have no meaning for outbound requests. If they are set dynamically (that is, if they are set in the $outbound headers section), they are ignored.4
These headers are received in $inbound. Date is the time the mail was sent by the sender. From is retrieved from incoming mail headers.
  • From
  • Date
 

1For example, if you set the JMSExpiration header to 1000, and at the time of the send, GMT is 1,000,000 (as a result of System.currentTimeMillis()), the resulting value of the JMSExpiration property in the JMS message is 1,000,1000

2Header names with the JMS_IBM prefix are to be used with respect to destinations hosted by an IBM MQ server

3For FTP and file proxies, there is an transport request header 'fileName'. The value of this request header is the name of the file being polled.

4From and Date headers are also not applicable for $outbound request headers for e-mail business services. So there is no point in setting these headers for e-mail business services.

Note: The same limitations around setting certain transport headers and metadata are true when you set the inbound and outbound context variables, and when you use the ALSB Test Console to test your proxy or business services.

 


Performing Transformations in Message Flows

Transformation maps describe the mapping between two data types. ALSB supports data mapping that uses the XQuery and the eXtensible Stylesheet Language Transformation (XSLT) standards. XSLT maps describe XML-to-XML mappings. XQuery maps can describe XML-to-XML, XML to non-XML, and non-XML to XML mappings.

The point in a message flow at which you specify a transformation depends on whether:

Transformations and Publish Actions

When transformations are designed in publish actions, the transformations have a local copy of the $outbound variable and message-related variables ($header, $body, and $attachments). Any changes you make to an outbound message in a publish action affect only the published message. In other words, the changes you make in the publish action are rolled back before the message flow proceeds to any actions that follow the publish action in your message flow.

For example, consider a message flow that deals with a large purchase order, and you have to send the summary of the purchase order, through e-mail, to the manager. The summary of the of the purchase order is created in the SOAP body of the incoming message when you include a publish action in the request pipeline. In the publish action, the purchase order data is transformed into a summary of the purchase order—for example, all the attachments in $attachments can be deleted because they are not required in the summary of the purchase order.

Transformations and Route Nodes

You may need to route messages to one of two destinations, based on a WS-addressing header. In that case, content-based routing and the second destination require the newer version of the document in the SOAP body. In this situation, you can configure the route node to conditionally route to one of the two destinations. You can configure a transformation in the route node to transform the document for the second destination.

You can also set the control elements in the outbound context variable ($outbound) to influence the behavior of the system for the outbound message (for example, you can set the Quality of Service).

See Inbound and Outbound Variables and Constructing Messages to Dispatch for information about the sub-elements of the inbound and outbound variables and how the content of messages is constructed using the values of the variables in the message context.

See also:

 


Constructing Service Callout Messages

When ALSB makes a call to a service via a service callout action, the content of the message is constructed using the values of variables in the message context. The message content for outbound messages is handled differently depending upon the type of the target service. How the message content is created depends on the type of the target service and whether you choose to configure the SOAP body or the payload (parameters or document), as described in the following topics:

SOAP Document Style Services

Messages for SOAP Document Style services (including EJB document and document-wrapped services), can be constructed as follows:

To illustrate how messages are constructed during callouts to SOAP Document Style services, consider a service callout action configured as follows:

Assume also that at run time, the request document variable, myreq, is bound to the following XML.

Listing 3-1 Content of Request Variable (myreq)
<sayHello xmlns="http://www.openuri.org/">
    <intVal>100</intVal>
    <string>Hello AquaLogic</string>
</sayHello>

At run time, the SOAP request header variable, reqheader, is bound to the following SOAP header.

Listing 3-2 Content of SOAP Request Header Variable (reqheader)
<soap:Header xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/
xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing">
    <wsa:Action>...</wsa:Action>
    <wsa:To>...</wsa:To>
    <wsa:From>...</wsa:From>
    <wsa:ReplyTo>...</wsa:ReplyTo>
    <wsa:FaultTo>...</wsa:FaultTo>
  </soap:Header>

In this example scenario, the full body of the message sent to the external service is shown in Listing 3-3 (the contents of the myreq and reqheader variables are shown in bold).

Listing 3-3 Message Sent to the Service as a Result of Service Callout Action
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing">
        <wsa:Action>...</wsa:Action>
        <wsa:To>...</wsa:To>
        <wsa:From>...</wsa:From>
        <wsa:ReplyTo>...</wsa:ReplyTo>
        <wsa:FaultTo>...</wsa:FaultTo>
    </soap:Header>
    <soapenv:Body>
        <sayHello xmlns="http://www.openuri.org/">
            <intVal>100</intVal>
            <string>Hello AquaLogic</string>
        </sayHello>
    </soapenv:Body>
</soapenv:Envelope>

Based on the configuration of the service callout action described above, the response from the service is assigned to the myresp variable. The full response from the external service is shown in Listing 3-4.

Listing 3-4 Response Message From the Service as a Result of Service Callout Action
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.
org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <env:Header/>
    <env:Body env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <m:sayHelloResponse xmlns:m="http://www.openuri.org/">
            <result xsi:type="xsd:string">This message brought to you by Hello AquaLogic and the number 100
            </result>
        </m:sayHelloResponse>
    </env:Body>
</env:Envelope>

In this scenario, the myresp variable is assigned the value shown in Listing 3-5.

Listing 3-5 Content of Response Variable (myresp) as a Result of Service Callout Action
<m:sayHelloResponse xmlns:m="http://www.openuri.org/">
    <result ns0:type="xsd:string" xmlns:ns0="http://www.w3.org/2001/XMLSchema-instance">
This message brought to you by Hello AquaLogic and the number 100
    </result>
</m:sayHelloResponse>

SOAP RPC Style Services

Messages for SOAP RPC Style services (including EJB RPC services) can be constructed as follows:

To illustrate how messages are constructed during callouts to SOAP RPC Style services, look at this example with the following configuration:

In this scenario, the body of the outbound message to the service is shown in Listing 3-6.

Listing 3-6 Content of Outbound Message
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <sayHello2 xmlns="http://www.openuri.org/">
            <intVal>100</intVal>
            <string >Hello AquaLogic</string>
        </sayHello2>
    </soapenv:Body>
</soapenv:Envelope>

The response returned by the service to which the call was made is shown in Listing 3-7.

Listing 3-7 Content of Response Message From the helloWorld Service
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <env:Header/>
    <env:Body env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <m:sayHello2Response xmlns:m="http://www.openuri.org/">
            <result xsi:type="n1:HelloWorldResult" xmlns:n1="java:">
                <message xsi:type="xsd:string">
                This message brought to you by Hello AquaLogic and the number 100
                </message>
            </result>
        </m:sayHello2Response>
    </env:Body>
</env:Envelope>

The message context variable output1 is assigned the value shown in Listing 3-8.

Listing 3-8 Content of Output Variable (output1)
<message ns0:type="xsd:string" xmlns:ns0="http://www.w3.org/2001/XMLSchema-intance">
This message brought to you by Hello AquaLogic and the number 100</message>

XML Services

Messages for XML services can be constructed as follows:

To illustrate how messages are constructed during callouts to XML services, take for example a service callout action configured as follows:

Assume also that at run time, the request document variable, myreq, is bound to the following XML.

Listing 3-9 Content of myreq Variable
<sayHello xmlns="http://www.openuri.org/">
    <intVal>100</intVal>
    <string>Hello AquaLogic</string>
</sayHello>

In this scenario:

Messaging Services

In the case of Messaging services:

For example, if the request message context variable myreq is bound to an XML document of the following format: <hello>there</hello>, the outbound message contains exactly this payload. The response message context variable (myresp) is bound to a reference element similar to the following:

<binary-content ref=" cid:1850733759955566502-2ca29e5c.1079b180f61.-7fd8"/>

 


Handling Errors as the Result of a Service Callout

You can configure error handling at the message flow, pipeline, route node, and stage level. The types of errors that are received from an external service as the result of a service callout include transport errors, SOAP faults, responses that do not conform to an expected response, and so on.

The fault context variable is set differently for each type of error returned. You can build your business and error handling logic based on the content of the fault variable. To learn more about $fault, see Fault Variable.

Transport Errors

When a transport error is received from an external service and there is no error response payload returned to ALSB by the transport provider (for example, in the case that an HTTP 403 error code is returned), the service callout action throws an exception, which in turn causes the pipeline to raise an error. The fault variable in a user-configured error handler is bound to a message formatted similarly to that shown in Listing 3-11.

Listing 3-11 Contents of the ALSB fault Variable—Transport Error, no Error Response Payload
<con:fault xmlns:con="http://www.bea.com/wli/sb/context">
  <con:errorCode>BEA-380000</con:errorCode>
  <con:reason>Not Found</con:reason>
   <con:details>
   .......
   </con:details>
    <con:location>
       <con:node>PipelinePairNode1</con:node>
       <con:Pipeline>PipelinePairNode1_request</con:Pipeline>
    <con:Stage>Stage1</con:Stage>
    </con:location>
</con:fault>

In the case that there is a payload associated with the transport error—for example, when an HTTP 500 error code is received from the business service and there is XML payload in the response—a message context fault is generated with the custom error code: BEA-382502.

The following conditions must be met for a BEA-382502 error response code to be triggered as the result of a response from a service—when that service uses an HTTP or JMS transport:

If the transport is HTTP, the ErrorResponseDetail element will also contain the HTTP error code returned with the response. The ErrorResponseDetail element in the fault contains error response payload received from the service. Listing 3-12 shows an example of the ErrorResponseDetail element.

Listing 3-12 Contents of the ALSB fault Variable—Transport Error, with Error Response Payload
<ctx:Fault xmlns:ctx="http://www.bea.com/wli/sb/context">
    <ctx:errorCode>BEA-382502<ctx:errorCode>
    <ctx:reason> Service callout has received an error response from the server</ctx:reason>
    <ctx:details>
        <alsb:ErrorResponseDetail xmlns:alsb="http://www.bea.com/...">
            <alsb:detail> <![CDATA[
. . .                 
]]>
            </alsb:detail>           <alsb:http-response-code>500</alsb:http-response-code>
        </alsb:ErrorResponseDetail>
    </ctx:details>
    <ctx:location>. . .</ctx:location>
</ctx:Fault>
Note: The XML schema for the service callout-generated fault is shown in XML Schema for the Service Callout-Generated Fault Details.

SOAP Faults

In case an external service returns a SOAP fault, the ALSB run time sets up the context variable $fault with a custom error code and description with the details of the fault. To do so, the contents of the 3 elements under the <SOAP-ENV:Fault> element in the SOAP fault are extracted and used to construct an ALSB fault element.

Take for example a scenario in which a service returns the following error.

Listing 3-13 SOAP Fault Returned From Service Callout
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
  <SOAP-ENV:Body>
    <SOAP-ENV:Fault>
      <faultcode>SOAP-ENV:Client</faultcode>
      <faultstring>Application Error</faultstring>
      <detail>
        <message>That’s an Error!</message>
        <errorcode>1006</errorcode>
      </detail>
    </SOAP-ENV:Fault>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The <faultcode>, <faultstring>, and <detail> elements are extracted and wrapped in an <alsb:ReceivedFault> element. Note that the faultcode element in Listing 3-15 contains a QName—any related namespace declarations are preserved. If the transport is HTTP, the ReceivedFault element will also contain the HTTP error code returned with the fault response.

The generated <alsb:ReceivedFault> element, along with the custom error code and the error string are used to construct the contents of the fault context variable, which in this example takes a format similar to that shown in Listing 3-14.

Listing 3-14 Contents of the ALSB Fault Variable—SOAP Fault

<ctx:Fault xmlns:ctx="http://www.bea.com/wli/sb/context">
    <ctx:errorCode>BEA-382500<ctx:errorCode>
    <ctx:reason> service callout received a soap Fault response</ctx:reason>
    <ctx:details>
        <alsb:ReceivedFault xmlns:alsb="http://www.bea.com/...">
            <alsb:faultcode
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">SOAP-ENV:Clien
            </alsb:faultcode>
            <alsb:faultstring>Application Error</alsb:faultstring>
            <alsb:detail>
                <message>T
hat’s an Error!</message>
                <errorcode>1006</errorcode>
            </alsb:detail>

          <alsb:http-response-code>500</alsb:http-response-code>
        </alsb:ReceivedFault>
    </ctx:details>
    <ctx:location> </ctx:location>
</ctx:Fault>

Note: The unique error code BEA-382500 is reserved for the case when service callout actions receive SOAP fault responses.

Unexpected Responses

When a service returns a response message that is not what the proxy service run time expects, a message context fault will be generated and initialized with the custom error code BEA-382501. The details of the fault include the contents of the SOAP-Body element of the response. If the transport is HTTP, the ReceivedFault element will also contain the HTTP error code returned with the fault response.

The XML schema definition of the service callout-generated fault details is shown in Listing 3-15.

Listing 3-15 XML Schema for the Service Callout-Generated Fault Details
<xs:complexType name="ReceivedFaultDetail">
        <xs:sequence>
            <xs:element name="faultcode" type="xs:QName"/>
            <xs:element name="faultstring" type="xs:string"/>
            <xs:element name="detail" minOccurs="0" >
               <xs:complexType>
                 <xs:sequence>
                        <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
                 </xs:sequence>
        <xs:anyAttribute namespace="##any" processContents="lax" />
               </xs:complexType>
            </xs:element>
            <xs:element name="http-response-code" type="xs:int" minOccurs="0"/>\
type="xs:int" minOccurs="0"/>
        </xs:sequence>
</xs:complexType>

<xs:complexType name="UnrecognizedResponseDetail">
        <xs:sequence>
            <xs:element name="detail" minOccurs="0" type="xs:string" />
        </xs:sequence>
</xs:complexType>

<xs:complexType name="ErrorResponseDetail">
        <xs:sequence>
            <xs:element name="detail" minOccurs="0" type="xs:string" />
        </xs:sequence>
</xs:complexType>

 


Handling Errors in Message Flows

The process described in the next paragraph constitutes an error handling pipeline for the stage of an error handler. In addition, an error pipeline can be defined for a pipeline (request or response) or for an entire proxy service.

The error handler at the stage level is invoked for handling an error; If the stage-level error handler is not able to handle a given type of error, the pipeline error handler is invoked. If the pipeline-level error handler also fails to handle the error, the service-level error handler is invoked. If the service-level error handler also fails, the error is handled by the system.The following table summarizes the scope of the error handlers at various levels in the message flow.

Table 3-8 Scope of Error Handlers
Level
Scope
Stage
Handles all the errors within a stage.
Pipeline
Handles all the errors in a pipeline, along with any unhandled errors from any stage in a pipeline.
Service
Handles all the errors in a proxy service, along with any unhandled errors in any pipeline in a service.

Note: All WS-Security errors are handled at this level.

System
Handles all the errors that are not handled any where else in a pipeline.

Note: There are exceptions to the scope of error handlers. For example, an exception thrown by a non-XML transformation at the stage level is only caught by the service-level error handler. Suppose a transformation occurs that transforms XML to MFL for an outgoing proxy service response message, it always occurs in the binding layer. Therefore, for example, if a non-XML output is missing a mandatory field at the stage level, only a service-level error handler can catch this error.

For more information on error messages and error handling, see “Error Messages and Handling” in Proxy Services: Error Handlers in Using the AquaLogic Service Bus Console.

You can handle errors by configuring a test that checks if an assertion is true and use the reply action configured false. You can repeat this test at various levels. Also you can have an error without an error handler at a lower level and handle it through an error handler at an higher level in message flow. In general, it is easier to handle specific errors at a stage level of the message flow and use error handlers at the higher level for more general default processing of errors that are not handled at the lower levels. It is good practice to explicitly handle anticipated errors in the pipelines and allow the service-level handler to handle unanticipated errors.

Note: You can only handle WS-Security related errors at the service level.

Generating the Error Message, Reporting, and Replying

A predefined context variable (the fault variable) is used to hold information about any error that occurs during message processing. When an error occurs, this variable is populated with information before the appropriate error handler is invoked. The fault variable is defined only in error handler pipelines and is not set in request and response pipelines, or in route or branch nodes. For additional information about $fault, see Predefined Context Variables .

In the event of errors for request/response type inbound messages, it is often necessary to send a message back to the originator outlining the reason why an error occurred. You can accomplish this by using a Reply with Failure action after configuring the message context variables with the response you want to send. For example, when an HTTP message fails, Reply with Failure generates the HTTP 500 status. When a JMS message fails, Reply with Failure sets the JMS_BEA_Error property to true. The ALSB error actions are discussed in “Error Messages and Handling” in Proxy Services: Error Handlers in Using the AquaLogic Service Bus Console.

An error handling pipeline is invoked if a service invoked by a proxy service returns a SOAP fault or transport error. Any received SOAP fault is stored in $body, so if a Reply with Failure is executed without modifying $body, the original SOAP fault is returned to the client that invoked the service. If a reply action is not configured, the system error handler generates a new SOAP fault message. The proxy service recognizes that a SOAP fault is returned because a HTTP error status is set, or the JMS property SERVER_Error is set to true.

Some use cases require error reporting. You can use the report action in these situations. For example, consider a scenario in which the request pipeline reports a message for tracking purposes, but the service invoked by the route node fails after the reporting action. In this case, the reporting system logged the message, but there is no guarantee that the message was processed successfully, only that the message was successfully received.

You can use the ALSB Console to track the message to obtain an accurate picture of the message flow. This allows you to view the original reported message indicating the message was submitted for processing, and also the subsequent reported error indicating that the message was not processed correctly. To learn how to configure a report action and use the data reported at run time, see Proxy Services: Actions in Using the AquaLogic Service Bus Console.

Example of Action Configuration in Error Handlers

This example shows how you can configure the report and reply actions in error handlers. The message flow shown in Figure 3-2 includes an error handler on the validate loan application stage. The error handler in this case is a simple message flow with a single stage configured—it is represented in the ALSB Console as shown in Figure 3-2.

Figure 3-2 Error Handler Message Flow

Error Handler Message Flow

The stage is, in turn, configured with actions (replace, report, and reply) as shown in Figure 3-3.

Figure 3-3 Actions in Stage Error Handler

Actions in Stage Error Handler

The actions control the behavior of the stage in the pipeline error handler as follows:

For configuration information, see “Error Messages and Handling” in Proxy Services: Error Handlers in Using the AquaLogic Service Bus Console.

 


Using Dynamic Routing

When you do not know the service you need to invoke from the proxy service you are creating, you can use dynamic routing.

For any given proxy service, you can use one of the following techniques to dynamically route messages:

Implementing Dynamic Routing

You can use dynamic routing to determine the destination during the runtime of a proxy service. To achieve this you can use a routing table in an XML file to create an XQuery resource.

Note: Instead of using the XQuery resource, you can also directly use the XML file from which the resource is created.

An XML file or the Xquery resource can be maintained easily. At runtime you provide the entry in the routing table that will determine the routing or publishing destination of the proxy service.The XML file or the XQuery resource contains a routing table, which maps a logical identifier to (such as the name of a company) to the physical identifier (the fully qualified name of the service in ALSB). The logical identifier, which is extracted from the message, maps on to the physical identifier, which is the name of the service you want to invoke.

Note: To use the dynamic route action, you need the fully qualified name of the service in ALSB.

In a pipeline the logical identifier is obtained with an XPath into the message.You assign the XML table in the XQuery resource to a variable. You implement a query against the variable in the routing table to extract the physical identifier based on the corresponding logical identifier. Using this variable you will be able to invoke the required service. The following sections describe how to implement dynamic routing.

Sample XML File

You can create an XQuery resource from the following XML file. Save this as sampleXquery.xml.

Listing 3-16 Sample XML File
<routing>
   <row>
      <logical>BEA Systems</logical>
      <physical>default/goldservice</physical>
   </row>
   <row>
      <logical>ABC Corp</logical>
      <physical>default/silverservice</physical>
   </row>
</routing>

Creating an XQuery Resource From the Sample XML

  1. In an active session, select Project Explorer from the left navigation panel. The Project View page is displayed.
  2. Select the project to which you want to add the XQuery resource.
  3. In the Project View page, select the XQuery resource from the Select Resource Type drop-down list. The Create XQuery page is displayed.
  4. In the Resource Name field, enter the name of the resource. This is a mandatory.
  5. In the Resource Description field, provide the a description for the resource. This is optional.
  6. In the XQuery field, provide the path to the XML you are using as an XQuery resource. Click on Browse to locate the file. Optionally, you can copy and paste the XML in the XQuery field. This is mandatory.
  7. Save the XQuery resource.
  8. Activate the session.

Creating and Configuring the Proxy Service to Implement Dynamic Routing

  1. In an active session, select Project Explorer from the left navigation panel. The Project View page is displayed.
  2. Select the project to which you want to add the proxy service.
  3. In the Project View page, select the Proxy Service resource from the Select Resource Type drop-down list. The General Configuration page is displayed.
  4. In the Service Name field of the General Configuration page, enter the name of the proxy service. This is mandatory.
  5. Select the type of service by clicking on the button adjacent to various types of services available under Service Type. For more information on selecting the service type, see Proxy Services: Actions.
  6. Click Finish. On the Summary page, click Save to save the proxy service.
  7. On the Project View page, click the Edit Message Flow icon against the newly created proxy service in the Resource table. The Edit Message Flow page is displayed.
  8. Click on the message flow to add a pipeline pair to the message flow.
  9. Click on Request Pipeline icon select Add Stage from the menu.
  10. Click on the Stage1 icon to and select Edit Stage from the menu. The Edit Stage Configuration page appears.
  11. Click Add Action icon. Choose Add an Action item from the menu.
  12. Choose the Assign action from Message Processing.
  13. Click on Expression. The XQuery Expression Editor is displayed.
  14. Click on XQuery Resources. The browser displays the page where you can import the XQuery resource. Click on the Browse to locate the XQuery resource.
  15. Click on Validate to validate the imported XQuery resource.