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.