This discussion is archived
6 Replies Latest reply: Dec 27, 2012 7:55 PM by Abhinav RSS

OSB: Payload validation required for empty elements inside OSB process.

961292 Newbie
Currently Being Moderated
Hello

I need to validate the payload for non-empty elements. If the payload is completely empty then OSB should throw an error that the submitted payload is empty.
If the payload contains at least one element then it should pass through.

As in process to test this particular one, i have tried with the following code to generally validate for an element.
*********************************************************************************************
xquery version "1.0" encoding "Cp1252";
(:: pragma bea:global-element-parameter parameter="$inputParameters1" element="ns0:InputParameters" location="../adapter/StoreProcDB/xsd/StoreProcDBService_sp.xsd" ::)
(:: pragma bea:schema-type-return type="ns1:Validation" location="../xsd/validation.xsd" ::)

declare namespace xf = "http://tempuri.org/StoreProc_osb/transformation/PayloadValidation/";
declare namespace ns1 = "http://www.sigmainfo.com/validation";
declare namespace ns0 = "http://xmlns.oracle.com/pcbpel/adapter/db/sp/StoreProcDBService";

declare function xf:PayloadValidation($inputParameters1 as element(ns0:InputParameters))
as element()
{
<ns1:Validation>
          <ns1:Payload>{$inputParameters1/.}</ns1:Payload>
          <ns1:ValidationErrorList>
          {
               (: BEGIN - Required Field Validations :)
          (:     if (empty($inputParameters1/ns0:ACCOUNTNUMBER/text())) then
                    <ns1:ValidationError>
                         <ns1:code>1</ns1:code>
                         <ns1:message>ACCOUNTNUMBER: Required Field</ns1:message>
                    </ns1:ValidationError> :)
               if (empty($inputParameters1/ns0:AUDITUSER/text())) then
                    <ns1:ValidationError>
                         <ns1:code>1</ns1:code>
                         <ns1:message>AUDITUSER: Required Field</ns1:message>
                    </ns1:ValidationError>
               else ''
               (: END - Required Field Validations :)
}
</ns1:ValidationErrorList>
     </ns1:Validation>
     };
     
declare variable $inputParameters1 as element(ns0:InputParameters) external;

xf:PayloadValidation($inputParameters1)

*********************************************************************************************
But it throws the following error:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
REQUEST DOCUMENT:
-------------------------------
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
</soap:Header>
<soapenv:Body>
<stor:InputParameters
xmlns:stor="http://xmlns.oracle.com/pcbpel/adapter/db/sp/StoreProcDBService">
<!--Optional:-->
<stor:P_ACCOUNTNUMBER>00101</stor:P_ACCOUNTNUMBER>
<!--Optional:-->
<stor:P_AUDITUSER>venkat</stor:P_AUDITUSER>
</stor:InputParameters>
</soapenv:Body>
</soapenv:Envelope>
--------------------------------------------------------------
RESPONSE DOCUMENT:
--------------------------------
The invocation resulted in an error: . <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body><soapenv:Fault><faultcode>soapenv:Server</faultcode><faultstring>BEA-382505: OSB Validate action failed validation</faultstring><detail><con:fault xmlns:con="http://www.bea.com/wli/sb/context">
<con:errorCode>BEA-382505</con:errorCode>
<con:reason>OSB Validate action failed validation</con:reason>
<con:details>
<con1:ValidationFailureDetail xmlns:con1="http://www.bea.com/wli/sb/stages/transform/config">
<con1:message>
Incompatible elements: expected an XML instance of name "{http://xmlns.oracle.com/pcbpel/adapter/db/sp/StoreProcDBService}InputParameters", but found an XML instance of name "{http://schemas.xmlsoap.org/soap/envelope/}Body".
</con1:message>
<con1:xmlLocation/>
</con1:ValidationFailureDetail>
</con:details>
<con:location>
<con:node>PipelinePairNode1</con:node>
<con:pipeline>PipelinePairNode1_request</con:pipeline>
<con:stage>stage1</con:stage>
<con:path>request-pipeline</con:path>
</con:location>
</con:fault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

But this is not the way it should be done as i progress.
Please suggest a simple way to have a pragma with sample and complete validation for the input payload.

Appreciate your help in advance
Regards
Venkat

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points