Tuesday, June 23, 2015

Oracle SOA: How to surround data around fields in file adapter

I was working on one of the usecase in which we need to surround single quote(') around the fields in output file during write operation in file adapter. For example:





Well the main logic for this is in the nxsd schema file that file adapter creates. I created a simple soa application, and the composite and bpel looks like below

In the transformation, I simply mapped the input parameter of request to file adapter input parameter.

here is my nxsd schema file:

you can download the soa project from here click here

Friday, June 19, 2015

Oracle OSB 12c: For each loop in oracle osb

Today I was working on one of the usecase in which I required to loop incoming records and pass each record to a service callout and send back response for each request as a collection. Well using foreach in OSB is not a big deal but yes due to lack of information sometimes you can stuck and take hours or day to resolve the issue. In this post I will explain a simple example in which I am passing the collection of names (FirstName and SecondName) and send back response after concatenate first name and second name as a full name. eg.


               <v1:Request xmlns:v1="http://xmlns.codeconfuse.com/XSD/foreach/V1">
<!--Zero or more repetitions:-->


              <tns:Response xmlns:tns="http://xmlns.codeconfuse.com/XSD/foreach/V1">
<Output>Anshul Mittal</Output>
<Output>code confuse</Output>

I have created two pipelines i.e. ContactPP and ForeachPP.


Below picture is the ContactPP pipeline

 Here in the Response Pipeline, inside replace activity used transformation to concat the Incoming payload (FirsName and SecondName) to outgoing payload(FullName).

Below is the snapshot of source of xslt:

<xsl:template match="/">
        <xsl:value-of select='concat (/ns0:InputRequest/ns0:FirstName, " ", ns0:InputRequest/ns0:SecondName )'/>


Below picture shows the ForeachPP pipeline:

Inside Request Pipeline, drag and drop the For Each activity and also drag and drop assign activity to set the value of Input parameter of service callout and output parameter as shown below:

For Each Activity

Configure for each activity as shown below:

Configure Service Callout as shown below:

Now set the input parameter ContactReq inside the assign activity as below:

Now transform the output of this service callout and save it to $TmpVar. This is similar to following

$TmpVar = $TmpVar + $ContactResp

Now we have the response of service callout in $TmpVar, and we need to transform into actual service output. This we can do it in Response Pipeline

Now in the first assign transform the data as shown below:

And save it to $TmpVar again. And in the next assign add the soap envelope to the out payload as below:

done, deploy and test.

Test Result

Download the project --> com.codeconfuse.foreach.zip

I hope this post helps you in understanding for each concept in OSB. There must be some other easy ways to do it, well I tried to keep it simple but if you have much better and easy way then please share it.

Saturday, February 7, 2015

Oracle OSB: error: cos-nonambig: Content model violates the unique particle attribution rule.

My team was building schema for the OSB service and SOA-BPM processes and they all are parallely working on the schemas. After completing the schemas we start testing in osb service and process, but in the osb we are getting the following exception:

servicebus:BusinessObjects/Payment/Payment/V1/xsds/PaymentBO.xsd:157:5: error: cos-nonambig: Content model violates the unique particle attribution rule.

So this error occurs at line 157, when I checked the this line I found this:

 <xsd:complexType name="PaymentAuthMod_Type"> -------- line 157
      <xsd:element ref="RqUID" minOccurs="0"/>
      <xsd:element ref="AsyncRqUID" minOccurs="0"/>
      <xsd:element ref="CustId" minOccurs="0"/>
      <xsd:element ref="Status" minOccurs="0"/>
      <xsd:element ref="EMVData" minOccurs="0"/>
      <xsd:element ref="NetworkTrnInfo" minOccurs="0"/>
      <xsd:element ref="POSData" minOccurs="0"/>
      <xsd:element ref="PmtAuthRec" minOccurs="0"/>
      <xsd:element ref="PmtAuthId" minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element ref="PmtAuthRec" minOccurs="0" maxOccurs="unbounded"/>


I have gone through some documentation of UPA Rule i.e. Unique Partition Attribution rule which says same element can not have more than one meaning e.g.

    <xsd:element name="abc" type="xsd:integer" minOccurs="0"/>
    <xsd:any minOccurs="0" maxOccurs="unbounded" />

Here, there is one possibility that  xsd:any can be as a element "abc".


    <xsd:element name="abc" type="xsd:integer" minOccurs="0"/>
    <xsd:element name="abc" minOccurs="0" maxOccurs="unbounded" />

So line 157 in my schema there is one element which is repeating with different meaning i.e.

    <xsd:element ref="PmtAuthRec" " minOccurs="0"/>
    <xsd:element ref="PmtAuthRec" minOccurs="0" maxOccurs="unbounded" />

So finally I removed one of the element and it worked.


  • http://www.w3.org/TR/xmlschema-1/#non-ambig
  • http://en.wikipedia.org/wiki/Unique_Particle_Attribution

Wednesday, February 4, 2015

Oracle OSB 12c: ORABPEL-15235, "Failed to translate JSON to XML" when processing a JSON Message

As we know in Oracle OSB 12c we got a new rest adapter to build and expose rest service from osb. So I was working on Rest adapter in osb and expose one of the rest service which is accepting the request in JSON format and sending the response in the same format. In rest service there are many parameters to be passed as request. So while testing this service from the osb console I am getting the following exception:

Translation Failure.
Failed to translate JSON to XML. 
The incoming data does not conform to the NXSD schema. Please correct the problem.


Caused by: java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at de.odysseus.staxon.base.AbstractXMLStreamReader.getTextCharacters(AbstractXMLStreamReader.java:529)
at oracle.tip.pc.services.translation.xlators.json.JsonSaxEventsGenerator.generateEvents(JsonSaxEventsGenerator.java:241)
at oracle.tip.pc.services.translation.xlators.json.JsonTranslator.translateFromNative(JsonTranslator.java:139)


Well for this error I have found a document in oracle support which says that this is the bug in Oracle OSB that when processing the JSON message if the size of the request is greater than 4096 then this error is thrown.
So oracle support has issued a patch to resolve this issue. Patch number is 18692809 and for more information on this please follow the Document ID 1948201.1 on Oracle Support.

Friday, January 30, 2015

Error: cos-element-consistent: Type of element is inconsistent with another element with the same name in this content model

I was working on the XML schema creation in Oracle Service Bus application, and I got the following issue while building the OSB service project:

Error: cos-element-consistent: Type of element is inconsistent with another element with the same name in this content model."/>

Later I found that some body has updated the schema with same element which is already there with some other type i.e.  I put  this element

<element name="ResponseStatus" type="ResponseStatus_Type" />

"ResponseStatus_Type" is simple type which is defined as follows:

<xsd:simpleType name="ResponseStatus_Type">
    <xsd:restriction base="String_Type">
      <xsd:maxLength value="64"/>

Now somebody else defined one more element with same name i,e "ResponseStatus" but different type like this:

<element name="ResponseStatus" type="string" />


Just remove the one of the definition of the element with same name.