Monday, March 23, 2015

Suppressing the Selection Failure exception in Assign activity – Oracle SOA

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.

########

0 comments: