Wednesday, November 8, 2023

JSON Conversion Issue To XML in BPEL - SOA Suite 12c

Problem :

When we invoke a REST API from BPEL we get JSON as response in most of the cases. This JSON can not be used directly in BPEL flow as the native data format is XML. We can use JavaScript though to process the JSON data. We normally use Translate activity to convert JSON to XML. But, during the conversion we often run into conversion/translation issue.


Solution:

If at all you run into the conversion issue, then create a string type variable and assign the JSON response of invoke activity to that string variable. Use this string variable that holds JSON as a string in translate activity, This should resolve the conversion issue as long as the JSON data format and NXSD format are the same.

Thursday, December 24, 2020

How to schedule OIC integration to run for every 2 minutes like SOA composite based on FTP adatper

In Oracle SOASuite, FTP/File adatper can poll on a folder for every few seconds and consume the files. Business cases in which a file has to be consumed in no time we can reduce the polling frequency as much as we can.

In OIC, the minimum schedule frequency is 10 minutes. There is no chance of reducing the frequency when we use Simple Schedule. In this situation, we can clone the same integration which processes the files into say 5 integrations and schedule them to run for every 10 miuntes and 2 minutes apart from each other.

Say Int1 and Int2 are scheduled to run for every 2 minutes starting from 10.10 AM and 10.12 AM respectively. With 5 such integrations we can run all these clones 5 times in 10 minutes.

However, when the integrations are working on the same directory, there may be chance of duplicates in downstream systems. We need to ensure all the files are processed before the next integration runs in its schedule. This often causes issues.

By using iCal expression this situation can be handled.

Using iCal expression we can schedule the integrations to run for every 2 miutes. 2 minutes is the minimum for iCal expression. We can't go less than that.

The expression to do this is as follow.

FREQ=DAILY;BYHOUR=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23;BYMINUTE=0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58;BYSECOND=0;

Above expression states that the schedule has to run for every 2 minutes for each hour.

Below is the screenshot of Simple Schedule


Below is the screenshot of iCal expression.


Following screenshot shows the schedule runs of above expression after running the schedule.








 

Thursday, October 15, 2020

OIC Integrations - Required procedure is not showing up in DB adapter invoke action's configuration in integration flow.

If you are facing an issue in not seeing the procedure in a package while configuring DB invoke, make sure that the procedure has atleast one parameter.

If a procedure is created without any parameter DB adatper in OIC integration won't show that procedure at all in the package you browsed. Create the procedure with at least one parameter and reconfigure the DB adapter invoke action.




Saturday, April 14, 2018

Steps To Create A User In Oracle Fusion Application And CSF Key In EM Console

Following are the navigation steps to create a user in Oracle Fusion Application. This user is used to  interact with Oracle Fusion Application's webservices from SOA services.

1. Login to fusion console. Click on the down arrow next to the user name in the right corner. Click Setup and Maintenance.


2. Click on Tasks Symbol on the right. Once the options are shown, click on Search.


3. Search Manage%Job%Roles%
    In the search result you can see Manage Job Roles. Click on it.




4. Navigate to Add User Account as shown below.






5. Click on Add User Account. Application will ask different details as shown below. Provide the required details.


6. Once you create the user. Add appropriate roles to that user. Following screen show the typical roles of the user which will be used in SOA application.





This is how we create a user in Fusion Application.
Now we see how to create this user's CSF account in Oracle 12c SOA EM Console.

Say the user we have created in Fusion Application is TESTINT. Password is welcome1.

Following are the steps to create CSF Key in EM Console.

1. Login to EM console. Navigate to Credentials as shown below.



2. Click on Credentials. Create Map and Create Key as shown in below screens. First create the Map. Next create the Key. In the Key creation time, select the Map name from the dropdown. Supply the username and password that you have created in Fusion Application.





Now we have created the CSF Key with the credentials already created in Fusion Application. Use this CSF Key in SOAP adapter or ERP Cloud adapter while invoking Oracle Fusion's webservices.

Wednesday, December 28, 2016

Using REST Adapter in 12c Service Bus with nXSD's XML as Input

In continuation to the previous post here, in this demo we will see how an XML fragment can be passed as input to the REST adapter in Service Bus instead of building query parameters and populate them in the $outbound variable.


Please follow everything in previous post until you create the REST adapter.
Now we will see what needs to be configure within the REST adapter.


1. Right click on the overview canvas and add REST service. Make sure that you have checked the check box down below the Type drop down. With this setting we can now call the REST adapter/service as a webservice. After completing the configuration, we can see WSDL file generated along with the WADL file corresponding to the REST adapter.

The main difference between previous demo and the present demo is this check box selection.


2.   In this step, we need to provide the URL, resource and operation details similar to the previous demo. Create a  new operation in Operation Bindings section of the window.
                                

3. In the new Operation window add a proper name to the operation and select the HTTP method as GET. In the Request parameter section, we need to specify the input which is now in XML format. To specify that we need to build the XML schema corresponding to the input XML. Now, click on the gear symbol next to the Schema URL text box.



4.  Native Format Builder wizard will pop up to build the schema, as below. Click Next


5.  Give a proper name to your schema. Click Next.


6. Based on the sample that we provide, a schema will be generated. Select XML Sample option and click Next.

7.  Provide a sample XML with required XML structure. And click Next.


8. The nXSD schema which is going to be generated will shown to you. Click Next. Once the REST adapter configuration is finished, you can see a new nXSD created for the input XML which will be input the REST adapter's business service.


9.  Now we have completed the schema. Click on Finish.



10.  Once the schema is built, the Operation Bindings window will look as below. In below screen shot, in parameter section, you can see Address and Key as the parameters. But GeoCode expects query parameters as lower case address and key. Please edit the parameters as lower case address and key.



11. In Response tab, select JSON and XML as the response format.

                   

12.  In previous demo we have created on nXSD for the response that is coming from GeoCode API. I am using the same nXSD here. Browse the nXSD in the search option just next to the Schema URL text box.


13. Once the schema is browsed, the Response tab looks as below. Since we have give the nXSD in the response section, the JSON response that is given by GeoCode will automatically be converted to XML.



 14. Finally the REST adapter window looks as below and click Finish.


15.  Now we need to invoke the REST adapter's business service from the pipeline. Create a pipeline. Inside the pipeline, add pipeline pair, stage and a service callout. In the service callout browse the Business Service corresponding to the REST adapter for GeoCode API.


16.  Now add an assign action inside the service callout's request action flow. With this assign action we will  populate $varInput variable. This input will be given to the GeoCode REST business service.



 For the elements AddressValue and KeyValue, the text value comes from the input payload of the pipeline.

17. Populate the output from REST adapter (from GeoCode API) in $body variable. This $body will be the output of the pipeline.

Monday, December 12, 2016

Using REST Adapter in 12c Service Bus with Query Parameters

In 12c Service Bus, we have REST adapter to invoke a REST based service. Earlier in 11g SOA Suite we used to use HTTP adapter for simple HTTP method based calls. With this adapter query parameters and XML were only means of data formats in communication. In 11g Oracle Service Bus we used HTTP based business service to achieve REST based communication. With 12c's REST adapter now we can invoke external service which is based on REST and we can send and receive data in JSON format.

Now, let us see a small 12c service bus program which invokes Google's GeoCode service to validate an address. In this demo, we send some address as input to the GeoCode API. In turn, GeoCode will send us the respective co-ordinates of the given address's location.

Before developing this program, please obtain a key from GeoCode by signing into your Google account. Just follow the steps that are provided by Google.
You can create a  GeoCode project and a key here.

Once you are ready with the GeoCode API key with your account, the end point which we need to invoke will look something like below.

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=AIzaSy***********wlwpFuD**********Xk

I, just striked out few characters in the key with asterisk symbol as it is the key owned by me.
Basically this URL has 2 inputs. One is the address and the other is the Key.

Before invoking the GeoCode service, please download the security certificate from any browser and add the certificate to the weblogic server keystore.

In this demo, I am using 12c integrated weblogic server.

Steps to add a security certificate to the keystore :

  • Download the security certificate from any browser after hitting above URL. Say, the certificate name is GeoCodeCertificate.cer.
  • Copy the security certificate to the lib directory of your Jdeveloper home directory. In my case, it is, D:\oracleJdev122\wlserver\server\lib. Of course, you can save the certificate any other directory. Just to not forget I have added in lib directory.
  • Go to Java's JDK bin where keytool executable utility is present. The path is something like C:\Program Files\Java\jre1.8.0_45\bin.
  • Now execute below command.
C:\Program Files\Java\jdk1.8.0_45\bin>keytool -import -trustcacerts -alias geoco
decert -file D:\oracleJdev122\wlserver\server\lib\GeoCodeCertificate.cer -keysto
re D:\oracleJdev122\wlserver\server\lib\DemoTrust.jks -storepass DemoTrustKeySto
rePassPhrase
Certificate was added to keystore

You will see that the certificate is now added to the keystore as above.


Now we are ready to build our service bus program.



I am using 12.2.1.0 version of Jdevloper.

Once you open the Jdeveloper, create a service bus application. Inside that application, create a service bus project.

Following are the steps to hit the GeoCode REST service.

  1. GeoCode service can give us response either in XML or JSON format. We now handle JSON response in service bus. Before that copy paste the URL given previously in your browser. Once the URL is hit, there will be a JSON response from GeoCode service. Copy the JSON payload and save it.
  2. Now create an NXSD file based on the JSON payload. We use NXSD to convert the JSON to XML and use that XML as the output of our pipeline.
  3. NXSD creation screen shots.
          Right click on the project and click new. Now select NXSD.




         NXSD creation wizard will pop up.

       

       Click Next. Give a proper  name to your NXSD. 
     

     
      Click Next. Select JSON Interchange Format type.
                                


     Click Next. Please keep everything default. Don't change the Root Element name. Paste the JSON response payload from GeoCode n the sample section.

                             


       Click Next. Native schema will be generated and shown. You can test if you want.

                               


     Click Next. Click Finish.



       Now an NXSD file is created. We use this file in NXSD transformation action at later point of time in the pipeline. Using this we convert the response JSON from GeoCode API to XML.

      4.  Open the overview page of the project and you can see a canvas. On the right side of the canvas, under External Services section right click and add REST service. In below screenshot there is already one REST service created which is part of the demo.

         

      5.  Once you select REST, a wizard will pop up. Give a proper name to the REST reference. Please observe that I haven't checked the box below the Type option.

                   

   
                             

         6. Click Next. Add base URI and add resource path as shown below. We will see method configuration in next step.
            
       
        7. In Methods section, click the Plus Symbol. REST Method Definition wizard will pop up. In this, provide a method name which is of your own. Leave the Resource value to default. In HTTP Verb dropdown, select GET method. We will see Request and Response parameters in next step.

                           
       
       8. Now click on Plus symbol in Request tab. Once you click on plus symbol, you will see Create URI Parameter wizard. In this give a parameter name and keep the defaults Style as query and Type as String.

                 


    9. Create one more parameter for GeoCode key. Once you create the final REST Method Definition wizard looks as below. Click OK.
  
                            

       10. Now the final REST Binding Configuration Wizard looks as below.


         11. Now create a pipeline on the overview canvas. Give appropriate name to the pipeline.
                
                
                     
        12. Click Next and provide the configuration details. Here I am choosing HTTP protocol. Input and output messages to and from the pipeline are in XML format.

                               
                             
       13. Open the pipeline and add a pipeline pair. Inside the request pipeline add a service callout and in that service callout browse the business service that is generated for the REST service adapter that you have created earlier. Following screenshot shows the service callout configuration along with business service browsed and the input and output variables declared.

                           


       14. Our aim is to call the GeoCode API. The input parameters are the HTTP name-value parameters. These parameters will go to the GeoCode API through the GET method. To send the address and key values, I am setting HTTP parameters inside the service callout just before calling the REST business service. This is done using insert action as shown below.

                            

   In this insert action, I have given below XQuery expression inside Value.

   <http:query-parameters>
          <http:parameter name="address" value="{$body//address}"/>
          <http:parameter name="key" value="{$body//key}"/>
   </http:query-parameters>

   Here, I am constructing <http:query-parameter> element for address and key HTTP Parameters respectively. For each parameter the value comes from the input XML that is already present in $body variable.
  Eventually address and key parameters will be populated in $outbound variable which will go to the business service.
  The above XML expression is added as first child of below XML Path inside the $outbound variable.
./ctx:transport/ctx:request

 NOTE : address and key are the parameters that we already created inside the REST adapter.

Now we are all set to call the business service with the required input.

  
    15.  But the output which is coming from the REST service is in JSON format. We will convert the JSON to XML using the nXSD Transalte action.

           In the response flow of service callout, add the nXSD Translate and configure as shown in below screenshot.

           

  In the configuration, you can see that the Transalation type is Native to XML i.e., JSON to XML. Input to the nXSD Transalte action will come from $varOutput (output variable of the service callout action).
Browse the NXSD in the static section.
nXSD Transalte action is assigned to $body variable only after conversion.
  


Once the response flow is finished we can see the JSON to XML converted output in $body variable.

Finally, the overview page looks as below.