Sunday, January 31, 2016

Oracle API Gateway : Getting started with FTPS server

In this blog post I going demonstrate how to create a FTPS server inside the Oracle API Gateway (OAG).

Below are the steps required to create FTPS server:

  • Generate SSL certificate for ftps server
  • Configure SSL certificate in OAG
  • Create ftps Incoming file policy
  • Create Password Authentication Policy
  • Create User in OAG
  • Configure ftps server in OAG
  • Test and verify ftps connection using client

Generate SSL certificate for ftps server

You need openssl to create ssl certificate. you can download the openssl from here : https://www.openssl.org/source/

Please follow below blog post to configure ssl certificate

http://www.codeconfuse.com/2016/01/how-to-generate-ssl-certificate-using.html

Configure SSL certificate in OAG

  • Open policy studio --> Go to Certificates and Keys --> Certificates --> Click on Create/Import



  • Import the certificate that you have created above, click on import certificate



  • Go to Private Key tab and import the private key

  • Click Ok and finish the certificate import wizard.

Create FTPS incoming file policy

This policy is used to handle the incoming file coming from the ftps client and this is required to create ftps server listener.
  • Under Policies --> Create container "File Transfer" --> Right click and Add Policy, give the name of the policy "FTPS Incoming"
  • Open the FTPS Incoming policy, from the right menu go to Routing --> drag n drop "Save to File" filter.


Note: For the demonstration purpose I am saving the file in local server, you can use other filters according to your usecases.

  • Open "Save to File" filter and configure as below
Create Password Authentication Policy

This policy required to authenticate the client using username and password.

  • Add new policy similary created for FTPS Incoming policy, give the name "Password Authentication"
  • Open the policy, from right menu go to Authentication --> drag n drop Attribute Authentication and configure as below

  • Click Finish.

Create a User in OAG
  • Go to Users and Groups --> Users --> Click on Add, add new user weblogic.


  • Click Ok.
Configure FTPS server in OAG
  • Go to Listeners --> Oracle API Gateway --> Right Click and selct "Add File Transfer Service"
  • Configure as shown below

  • Select Password Authentication policy and FTPS Incoming policy as shown in the picture above
  • Select the IA server Cert that you have created above.
  • The directory used above is default directory, you can change this directory by putting folder name like ${environment.VINSTDIR}/file-transfer/in/weblogic

Test FTPS server connection

You can use any client like Filezilla or WinScp to test the FTPS connection. 
Use the user weblogic that is created in Oracle API Gateway.

Reference
  • https://docs.oracle.com/cd/E39820_01/doc.11121/gateway_docs/content/general_file_transfer.html

Friday, January 29, 2016

java.lang.Error: Critical Error. Failed to write transaction file /osb/configfwk/core_wls_osb1/_xact_ctrl.ih

Sometimes when you deployed the osb project using /sbconsole you will get the following exception while activating the project i.e.


Cause: 

The possible reason for this exception is the disk is full

Solution:

Check the disk space using the follwoing command

df -h

if the disk is full, then empty the space by deleting the logs file.

Saturday, January 23, 2016

Oracle API Gateway 12c : Getting started with SFTP server

In this blog post I going demonstrate how to create a SFTP server inside the Oracle API Gateway (OAG).

Below are the steps required to create SFTP server:

  • Generate SSL certificate for sftp server
  • Configure SSL certificate in OAG
  • Create SFTP Incoming file policy
  • Create Password Authentication Policy
  • Create User in OAG
  • Configure SFTP server in OAG
  • Test and verify SFTP connection using client


Generate SSL certificate for sftp server

You need openssl to create ssl certificate. you can download the openssl from here : https://www.openssl.org/source/

Please follow below blog post to configure ssl certificate

http://www.codeconfuse.com/2016/01/how-to-generate-ssl-certificate-using.html

Configure SSL certificate in OAG

  • Open policy studio --> Go to Certificates and Keys --> Certificates --> Click on Create/Import



  • Import the certificate that you have created above, click on import certificate




  • Go to Private Key tab and import the private key

  • Click Ok and finish the certificate import wizard.

Create SFTP Incoming Policy

This policy is used to handle the incoming file coming from the sftp client and this is required to create sftp server listener.
  • Under Policies --> Create container "File Transfer" --> Right click and Add Policy, give the name of the policy "SFTP Incoming"
  • Open the SFTP Incoming policy, from the right menu go to Routing --> drag n drop "Save to File" filter.

Note: For the demonstration purpose I am saving the file in local server, you can use other filters according to your usecases.

  • Open "Save to File" filter and configure as below



Create Password Authentication Policy

This policy required to authenticate the client using username and password.

  • Add new policy similary created for SFTP Incoming policy, give the name "Password Authentication"
  • Open the policy, from right menu go to Authentication --> drag n drop Attribute Authentication and configure as below

  • Click Finish.

Create a User in OAG
  • Go to Users and Groups --> Users --> Click on Add, add new user weblogic.


  • Click Ok.

Configure SFTP server in OAG


  • Go to Listeners --> Oracle API Gateway --> Right Click and selct "Add File Transfer Service"
  • Configure as shown below


  • Select Password Authentication policy and SFTP Incoming policy as shown in the picture above
  • Select the IA server Cert that you have created above.
  • The directory used above is default directory, you can change this directory by putting folder name like ${environment.VINSTDIR}/file-transfer/in/weblogic

Test SFTP server connection

You can use any client like Filezilla or WinScp to test the SFTP connection. 
Use the user weblogic that is created in Oracle API Gateway.

Reference
  • https://docs.oracle.com/cd/E39820_01/doc.11121/gateway_docs/content/general_file_transfer.html


How to generate ssl certificate using openssl

This blog post is about how to create ssl certificate using openssl. you require openssl software to create certificate so you can download the openssl binaries from here
https://www.openssl.org/source/

Below are the steps required to create ssl certificate

  • Create Root CA Key
  • Create Root CA based on the CA Key
  • Create Subordinate certificate key
  • Create subordinate certificate request 
  • Signed the subordinate certificate with the Root CA


Create Root CA Key

genrsa -out ca.key 1024

This command create 1024-bit key with no password







genrsa -des3 -out ca.key 1024

This command generate 1024-bit key with password




Create Self Signed Root CA

req -new -x509 -days 730 -key ca.key -out ca.crt

ca.crt is root ca which is valid for 2 years.

Create subordinate certificate key

genrsa -out ia.key 1024

The key generated is 1024-bit with no password, you can create with password as created above for  Root CA.

Note: Size of the key should be same

Create subordinate certificate request

req -new -key ia.key -out ia.csr


Signed subordinate certificate with Root CA

x509 -req -days 365 -in ia.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out ia.crt



This is a signed certificate valid for 1 year and used for actual signing. so use the ia.crt as certificate and ia.key its private key.

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