Tuesday, December 28, 2010

HTTP binding in Soa Suite 11g PS2

With Patch Set 2 of Soa Suite 11g Oracle added the HTTP Binding to the supported Adapters. This Adapter was already a feature of Soa Suite 10g, so it is great news that is back. So when your HTTP Service returns a XML message then you can use this binding in your composite application. When the HTTP Service has a  JSON response then you can use the Spring Context Component ( With PS2 Spring Context is supported ). Lucas made a great example how you can achieve this.

In this blogpost I will show how you can use this HTTP Binding as a Service or as a Reference Adapter. I start with a Service so I can use this Service later in the Reference Adapter.
Drag the HTTP Binding from the Component Palette to the Service part of the Composite. Use Service as Type and when you want to have this Service, to return a message then you should select Request-Response as Operation Type.


Provide the Request and Response XSD and choose the right element. For the Request Message Schema you can also use the wizard.

 

Next step is to wire this Service to a component. Choose a BPEL component and use the Define Service Later template.

Make a wire between the Service and the BPEL component.


Open the BPEL component and a Receive and Reply Activity and finish your BPEL. When everything is valid then you can deploy this to the Soa Suite Server.

For this HTTP Binding Service Soa Suite adds two Port types to the WSDL. This means you can also invoke this Service with a SOAP message

<wsdl:service name="execute">
        <wsdl:port name="Request_Response_pt" binding="tns:Request_Response_ptHttpGET">
            <http:address xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"  location="http://laptopedwin.wh.lan:8001/soa-infra/services/default/HttpBinding/execute%22/>
        </wsdl:port>
        <wsdl:port name="Request_Response_pt_soappt"
binding="tns:Request_Response_pttBinding">
            <soap:address xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
location="http://laptopedwin.wh.lan:8001/soa-infra/services/default/HttpBinding/execute%22/>
        </wsdl:port>
    </wsdl:service>

The Best way to test this HTTP Service is to open the endpoint url in a browser
http://laptopedwin.wh.lan:8001/soa-infra/services/default/HttpBinding/execute
This one is better then the tester of the Enterprise manager

Here you can choose for the normal Invoke ( Soap message ) or use REST POST or GET

 Or you can use the HTTP analyzer of JDeveloper, this is a great way to see the raw request and response

The HTTP binding can also be used as a Reference adapter. For example you can use the just created Service as Endpoint. Provide the Request and Response Schema's.


To test this Reference Adapter you can add a Mediator component with the same Request and Response Schema's. Expose this Mediator as a Service and wire the Reference Adapter to the Mediator and complete the routing rule.

Deploy this composite application, invoke the Mediator Service and take a look at the instances in the Enterprise Manager

2 comments:

  1. Hi

    I am also trying to set Header while making a HTTP POST call using HTTP Bindings adapter. I am not able to get any do so.Please help me.I have to set

    Content-type: application/octet-stream

    Please suggest.

    ReplyDelete
  2. Iam getting null pointer exception when i try to open endpoint URI. But Iam able to hit the http get method of my BPEL using direct URL in the browser as Http:\\endpoint?param=1&operationName=request-Response.

    ReplyDelete