Thursday, January 23, 2014

OSB 11g - Publish Activity In OSB

In this post, I will show you how to use Publish activity inside OSB to call external service. We have created a one-way SOA composite and deployed it to server, we will call this service from OSB using Publish activity.

First create a one-way SOA composite and deploy it to server. Then create a OSB project and add required folders (business, proxy, resources) to it.

Under resources folder add/import SOA composite schema and WSDL file.



Now go to business folder and create a business services based on SOA composite WSDL. Accept defaults and complete your business service creation.



Now we will create proxy service based on same WSDL file.



Now go to message flow of proxy service and add Pipeline pair to it.

In the request pipeline add Stage activity.



Inside stage, add Publish activity to call external service.



Click on “Service” link and choose newly created business service.



Choose external service operation.

Now we will do external service request message assignment. In this Post we are using same WSDL for proxy & business service so we really don’t required to assign value to request message of external service, but to show how to assign value if WSDL file is different for proxy & business service.



Here we are assigning constant value to external service request message.




 Once Proxy service is complete. Activate the session and test the proxy service.

 Testing Results






 Sample Code can be downloaded from here.


SOA 11g - Replace JCA File Properties Using Config Plan

When we migrate our code to next environment, we need to replace certain properties inside JCA file, like physical directory, polling frequency etc. we use config plans to replace these properties.

Suppose I have one FTP adapter and I am reading file from FTP from one specified location.

<adapter-config name="Ftp_FileListing" adapter="FTP Adapter" wsdlLocation="Ftp_FileListing.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
    <connection-factory location="eis/Ftp/system" UIincludeWildcard="test*.txt"/>
  <endpoint-interaction portType="FileListing_ptt" operation="FileListing">
    <interaction-spec className="oracle.tip.adapter.ftp.outbound.FTPListInteractionSpec">
      <property name="PhysicalDirectory" value="/dev/read/salesorder/"/>
      <property name="IncludeFiles" value="test.*\.txt"/>
    </interaction-spec>
  </endpoint-interaction>
</adapter-config>



To replace PhysicalDirectory property inside JCA file, go to wsdlAndSchema section of config plan.
Mention below property if you want to replace Physical Directory property.

<jca:property name="PhysicalDirectory"><replace>/test/read/salesorder/</replace></jca:property>


   <wsdlAndSchema name="Ftp_Readfile.jca">
      <jca:property name="PhysicalDirectory"><replace>/test/read/salesorder/</replace></jca:property>
   </wsdlAndSchema>
      


You can also replace below properties inside JCA file.

<jca:property name="DeleteFile"><replace>true</replace></jca:property>
<jca:property name="PollingFrequency"><replace>3</replace></jca:property>

Friday, January 10, 2014

OSB 11g - Call RESTful service from OSB

In my previous posts, I discussed about how to create RESTful web service and how to call RESTful service from SOA.

In this post, I will show you how we can call RESTful service from Oracle Service Bus.

We will use below RESTful web service which we created in previous post.

http://localhost:8001/soa-infra/services/default/RESTfulService/http_Client?input=test&operationName=Request-Response

To create project in OSB first we need to create a session and add new OSB project. Add required project folders to this project. Your project should look like below.

CallRESTfulService


    • business
    • proxy
    • resources


    Go to business folder and start with Business service creation, which in turn call our RESTful service. Give your business service a name and choose “Message Service” as Service Type. 
    Choose Request Message Type as “None” and Response Message Type as “Text”.


    Choose “http” from protocol drop-down list and add RESTful web service endpoint to Endpoint URI. Make sure you don’t add full URI, don’t include parameter when you mention URI here. Click on “Add” to add your service URI.

    Choose HTTP Request Method as “GET” from drop-down list.


    Accept default and save your Business service. Your Business service creation is complete.

    You can test your business service to check whether it successfully call RESTful service. Make sure you activate your session before testing your business service.

    We use below request message to test our Business Service.


    Below is the response from RESTful service to Business Service.




    Now we will create a proxy service which will call above created business service and pass required query parameters to business service.

    Go to proxy folder and create a proxy service, name your proxy service and choose “Business Service” as Service Type. Browse to already created business service and click next.




    Accept defaults and complete your proxy service creation. Now we need to pass required query parameters to business service which in turn uses these parameters to call RESTful web service.

    We use Insert activity to pass required parameters to business service.

    To add required insert activates go to proxy service message flow and add Insert activity to it.


    First Insert action will add “http-method” to outbound request.
    To do that click on expression link of Insert activity and add below text to it.

    <http:http-method>GET</http:http-method>
    Click on <Xpath> link and choose “transport/request” element as we will add “http-method” as a child of outbound transport request.



    First Insert activity should look like below.




    Add another Insert activity, in this Insert activity we will add query-parameters element to outbound request message. Click on expression link and add below text to it.

    <http:query-parameters/>
    Click on <Xpath> link and choose “transport/request” element as we will add “query-parameters” as a child of outbound transport request.



    Now we need to add two query parameters which are required to call that RESTful service. Add first parameters by adding another Insert activity. Click on expression link and add bellow text to it.

    <http:parameter name="operationName" value="Request-Response"/>

    Above element will add as a child of <http:query-parameters> element.



    Do it same for another query parameter.

    <http:parameter name="input" value="test"/>
    Your proxy service message flow will have total 4 insert activities now.

    Activate your session and test your proxy service.

    You can see below outbound message and clearly see all the required information in this message which is required to call RESTful service.



    When you test your proxy service, you may receive below error message.



    To resolve this error, we need to add proper encoding, to do that we need to add another Insert activity to message flow of proxy service.
    Above element will be added as child of outbound “transport/request” element.




    Below is your final message flow.



    Again test your proxy service.

    Testing Results



    Sample code can be downloaded from here.


    Thursday, January 9, 2014

    SOA 11g - Call RESTful service from SOA

    In previous post, we discussed about how to create RESTful service in SOA. Here we will discuss how we can call that service from oracle SOA.


    Create one SOA project and add synchronous BPEL to it.



    Configure HTTP Binding adapter to call RESTful service.


    Specify RESTful service endpoint and choose request and response schema elements. Use same schema that we used in previous post.


    Now wire your BPEL process with HTTP Binding adapter.


    Inside BPEL, add Invoke activity and link it to HTTP Binding adapter.


    Below is the final flow of BPEL process. Add required request and response mapping.


    Deploy your process and test it.

    Testing Results



    Download sample code from here.


    SOA 11g - Create RESTful Service In Oracle SOA

    There are two types of web services. SOAP and REST web services. We usually deal with SOAP web services in Oracle SOA but we can also create RESTful web services in SOA.

    RESTful web services are built to work best on the Web. Representational State Transfer (REST) is an architectural style. In REST data can be transmitted over a standardized interface (such as HTTP).

    This post shows how we can create RESTful web service in Oracle SOA. Follow below steps to create it.
    We will use below schema for this post.


    First create one SOA project. In composite.xml file drag “HTTP Binding” adapter and start configure it.



    Choose “service” from type drop-down list.

    Choose request and response element from your schema.

    Once you create HTTP binding adapter, drag a BPEL process to composite.xml file.


    Wire your BPEL process with HTTP adapter.


     Inside BPEL process, add receive activity and link it to HTTP adapter to receive the request.


    Add reply activity and link it to HTTP adapter to send the response back.

    Deploy your composite.

    You can test your composite using below URL.

    http://localhost:8001/soa-infra/services/default/RESTfulService/http_Client?input=test&operationName=Request-Response


     Testing Results

    Sample Code for this Post

    Friday, January 3, 2014

    BAM 11g- Call External Webservice From BAM Using Alerts

    BAM is mainly used for monitoring and reporting purpose. We also have alerts in BAM which can perform different operations; one of it is Call External Web Service whenever required.

    In this post, I will show you how you can configure alerts in BAM to invoke external web service.
    We have prepared one use case, in this use case first we will pass data from First Composite to BAM Data Object then by using alert we will call second Composite.

    ·         First Create one Data Object in BAM (refer Create Data Objects in BAM)
          ·         Create a first simple Composite. In this we will send the data to Bam Data Object. We can perform this action by two ways.

    ·         Using BAM Adapter (refer Connect to Bam using Bam Adapter)
                      ·         Using Sensors (refer Connect to Bam using BPEL Sensors)


    Now we need to create one alert In BAM, that alert will call second Composite or external web service.

    To add alert, choose Alerts from drop down list.



    Click on “Create a new alert” to create new alert.
    Once you click on above link, it will open a pop-up window. Click on “Create a Rule”.
    You will see various events listed so we need to can choose one event.


    We will choose “When a data field in a data object meets specified conditions”.
    Then click on above link. This will open below pop –up window. Choose your Data Object.


    Click on “add new entry” to add new rule. We need to specify one condition to start the alert.  So when ever Name will come as Vivek then this alert will trigger.


    Now click on “add entry” to add this entry. And click ok button.

    We will get following picture. Then click on Next button.
    Now we need to select one action that should be performed when this alert triggered. Click on “Call a web service”.
    Then click on configure web service.
     The click on configure web service; it will open below pop up window. Fill the External web service WSDL URL there.
    Now click on “Display Operations”. This will display all the operations that are there in External web service WSDL file. Now click on “Map Parameters”.

     

    Now we need to map Data object fields to second composite input. After mapping click on OK button. Alert is created.