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:

Input:

<QuoteFileInput>
    <QuoteFile>
        <F1>A<F1>
        <F2>B<F2>
        <F3>C<F3>
        <F4>D<F4>
    <QuoteFile>
<QuoteFile>
        <F1>E<F1>
        <F2>F<F2>
        <F3>G<F3>
        <F4>H<F4>
    <QuoteFile>

<QuoteFileInput>

Output:








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.

Inputs:

               <v1:Request xmlns:v1="http://xmlns.codeconfuse.com/XSD/foreach/V1">
<!--Zero or more repetitions:-->
<v1:PersonList>
<v1:FirstName>Anshul</v1:FirstName>
<v1:LastName>Mittal</v1:LastName>
</v1:PersonList>
<v1:PersonList>
<v1:FirstName>code</v1:FirstName>
<v1:LastName>confuse</v1:LastName>
</v1:PersonList>
</v1:Request>

Outputs:

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


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

ContactPP

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="/">
    <ns0:OutputResponse>
      <ns0:FullName>
        <xsl:value-of select='concat (/ns0:InputRequest/ns0:FirstName, " ", ns0:InputRequest/ns0:SecondName )'/>
      </ns0:FullName>
    </ns0:OutputResponse>
  </xsl:template>

ForeachPP

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:sequence>
      <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"/>
    </xsd:sequence>
  </xsd:complexType>

Solution:

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:sequence>
    <xsd:element name="abc" type="xsd:integer" minOccurs="0"/>
    <xsd:any minOccurs="0" maxOccurs="unbounded" />
  </xsd:sequence>

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

OR

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


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.

References

  • 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.

 ORABPEL-15235

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)

Solution:

Well for this error I have found a document in oracle support which says that this is the bug in Oracle OSB 12.1.3.0 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"/>
    </xsd:restriction>
  </xsd:simpleType>

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

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

Solution

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

Sunday, November 30, 2014

Oracle BPM 12c: Exception thrown while creating a Business Object (BO) based on external XSD


I was working on  the oracle bpm and creating a bpmn process. while creating a Business Object I am getting an error and is something related to “unable to parse the external xsd”.
Well after that I continues to a bpmn process and create a data object, but in the data association mapping I can’t see all the elements under the root element which in the xsd. As you can see in the figure below:

No elements visible under CustomerBO and requestBMHeader.

This is a known issue in Oracle bpm 12c, you can check here : 
In this page search for : Exception thrown while creating a Business Object (BO) based on XSD

Solution:


Well you can bypass this problem by manually mapping or assigning the value into your BPMN process i.e. Process.bpmn in this example.
Or
You can use the transformation to map the elements.

I think mapping elements using transformation is simple way to do that and I have done using the same and it worked successfully.

Friday, October 31, 2014

Oracle MFT 12c: Getting started with Oracle Manage File Transfer 12c

In large organization sometimes there is a requirement to transfer the files from one location to another location and file in source location is in different format than at destination for example at source destination the file may be .zip and in the destination you have to save in .xml. Oracle Managed File Transfer is one of the utility which provide this functionality and many more.

Oralce MFT Features

  • You can schedule the file transfer.
  • Resubmitting the transfer to redeliver the file.
  • Compression and decompression of file.
  • Encryption and decryption of files.
  • Archiving, renaming and deletion.
  • you can pause and resume the file transfer.
  • Detailed auditing and reports of file transfer.
  • Transfer of files from single source to multiple targets.

Components of Oracle MFT

Oracle MFT Artifacts

There are three main artifacts which are used for Managed File Transfer:

Source: It defines the origin of file i.e. location of the file which is going to picked by MFT server.

Transfer: This artifacts links one source to one or more targets. You can also create the content filters or can perform the actions like encryption/decryption or compresseion/decompression.

Targets: It is the destination location where the transfer put the file or the content.



Embedded Ftp and sFtp server in weblogic

In Oracle MFT 12c these two servers are embedded to weblogic can be used as one of the source artifacts, you need to configure host, port, user access to the directories in the MFT console as shown below:

By default the Ftp server is up and running, the only thing required for the Ftp server is location i.e. you have to pass the source location of files, default location is set to /u01/app/oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/mft/ftp_root/payloads. You can change this location if you want.

Monitoring and Reports

In Oracle MFT you get the separate page view or dashboard to monitor the mft instances. You can closely watch Source, Transfer and Targets instances separately. You can monitor the following things:

  • Success and failure instances for the source, transfer and target. You can also check the frequency of the statistics.
  • Dashboard got the separate error information table, so you can easily locate the error instances.
  • Separate view of active deliveries progress table.
  • Report generation for all or individual deliveries.


References:

http://docs.oracle.com/middleware/1213/mft/MFTUG/mftug_intro.htm#MFTUG269
http://docs.oracle.com/middleware/1213/mft/MFTUG/mftug_monitor.htm#CHDDGDAH