Saturday, May 16, 2015

Suppressing the Selection Failure exception in Assign activity – Oracle SOA Suite

Suppressing the Selection Failure exception in Assign activity – Oracle SOA Suite

This post will explain how to suppress the Selection Failure exception BPEL Assign activity – Oracle SOA Suite
In BPEL Assign activity if the xpath returns empty result then SelectionFailure RuntimeFault will be thrown by the engine.

But some cases we may need to suppress the selectionFailure error while assigning the optional elements.

In my case I have a assign activity that will mapthe elements  input and input1 from inputVariable to result and result1 of outputVariable.


The input2 is optional and somecases input2 element  will not be available in the request payload.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sup="http://xmlns.oracle.com/Application1/SuppressSelectionFailure/SuppressSelectionFailure">
   <soapenv:Header/>
   <soapenv:Body>
      <sup:process>
         <sup:input>?</sup:input>
      </sup:process>
   </soapenv:Body>
</soapenv:Envelope>


While invoking the service I am getting the selectionFailure exception as shown below.

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Header/>
   <env:Body>
      <env:Fault>
         <faultcode>env:Server</faultcode>
         <faultstring>faultName: {{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure}
messageType: {{http://schemas.oracle.com/bpel/extension}RuntimeFaultMessage}</faultstring>
         <faultactor/>
         <detail>
            <exception/>
         </detail>
      </env:Fault>
   </env:Body>
</env:Envelope>

I want to suppress the selectionFailure exception because input2 is a optional element .

The ignoreMissingFromData attribute will help us to suppress the selectionFailure if the target is missing in the copy operation.

<copy bpelx:ignoreMissingFromData="yes|no"/>



Now even though the input1 element is missing in the request the assign activity will not throw the selectionFailure exception instead the empty tag will get assigned to the outputVariable.


The bpelx:insertMissingToData attribute will help us to suppress the selectionFailure if the target is missing in the copy operation.

<copy bpelx:insertMissingToData="yes|no"/>

If the xpath in the copy operations returns empty node for the target then we will be getting exception "The assign activity of the to node query is returning zero node"



Configure the attribute bpelx:insertMissingToData will help us to suppress this error.

 <copy bpelx:insertMissingToData="yes">
        <from variable="inputVariable" part="payload"
              query="/client:process/client:input1"/>
        <to variable="outputVariable" part="payload"
            query="/client:processResponse/client:result1"/>
      </copy>

The runtime will crate the to-spec element if it is missing and assign the source value(used Remove operation to remove the result1 element from outputVariable for testing).



The attributes insertMissingToData and ignoreMissingFromData can be added by righ clicking the copy rules.



4 comments:

  1. Hi Albin,

    Thanks foe the post, it helped me.

    I have another question, how to suppress run time error in BPEL. For an instance, there is an invoke activity inside while loop. I want to continue the flow, if still there is any error while executing invoke activity.

    Thanks,
    Nataraj D

    ReplyDelete
    Replies
    1. Define a separate scope for invoke activity, catch all the exception in the scope level with empty activity

      Delete
  2. Hi Albin,

    I'm getting Selection Failure exception in Assign Activity for Append in foreach

    But copy operation is working and append is getting the selection failure.
    there is any other way to do this.

    Thanks in advance.

    ReplyDelete
  3. is it only used in catch activity or we can use it in main code too (i.e. not in the catch block)

    ReplyDelete