Friday 28 December 2012

REST services in SOA 11g using HTTP Binding

Invoking REST services in SOA 11g using HTTP Binding 

If you want to invoke HTTP methods like GET or POST in SOA composite application for that HTTP Binding Adapter is available that can be use to invoke REST services. For example if you have a web application that has a servlet that takes HTTP GET request with some parameter and returns an XML response.

So here I am demonstrating with an example. Create a SOA project with empty composite

Create an sample xsd

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns="http://www.example.org"
            targetNamespace="http://www.example.org"
            elementFormDefault="qualified">
  <xsd:element name="Request">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="FName" type="xsd:string"/>
        <xsd:element name="LName" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="Response">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="Name" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

Drop a Http Binding adapter in exposed services name it HttpTest click next in HTTP Binding Configuration.









 

 

 

 

Here you can specify type as service or reference, service type one way or request response, operation name and type of HTTP GET or POST.
In Request message either you can select existing element from a schema or select the wizard to create it .

 
Create a bpel process with Define Service later template


 
Wire service and bpel process


 
In Bpel process drop a receive activity with create instance checked and connect it with partner link


 In assign activity use concat function to assign name to output variable.

Deploy the application and for test through web browser

EndPoint- http://localhost/soa-infra/services/default/SampleHttp/HttpTest
Then request parameter FName and LName
operationName=Request-Response

8 comments:

  1. A good that explains exposing BPEL project as a RESTful service. It doesn't invoke/call a RESTful web service from a BPEL project. Please publish an article that will invoke a Web application using GET or POST Http methods.

    ReplyDelete
  2. Thanks for your post and I am doing a similar demo project.
    Dose the example xsd works or I have to specify another xsd? When I test it, it seems that the service cannot be invoked.

    Thanks!

    ReplyDelete
    Replies
    1. Hi Qian,
      The above specified xsd will work. if you have any HTTP GET or POST request. You can create the input request based on the request parameter accepted by HTTP request and same way create the response, what HTTP response you back and configure it through HTTP Binding Adapter.For Demo purpose you can create a Servlet like above that accept firstname and lastname as HTTP get or post and response back fullname.


      Regards,
      Pankaj

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Simple and easy especially for services that only publish REST services. Thanks

    ReplyDelete
  5. Thanks for sharing this great information I am impressed by the information that you have on this blog. Same as your blog i found another one Oracle SOA . Actually I was looking for the same information on internet for Oracle SOA and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can learn more aboutOracle SOA . By attending Oracle SOA Training .

    ReplyDelete