Friday, September 19, 2014

REST stands for Representational State Transfer. Restful service is an alternative to SOAP web service. Restful application use HTTP to transfer the data. In previous version of SOA suite there were very limited support for REST, we use HTTP bindings in 11g to create restful service. Click here to see how to create Restful service is SOA 11g. In SOA 12c additional feature provided for REST, REST bindings introduced which helps to create REST enable service and reference components.

In 12c we can integrate external REST API’s and XML, JSON and URL-encoded GET/POST data support is provided. Web Application Description Language (WADL) support is also provided, WADL is similar to WSDL only difference is WADL file is used when we create or Invoke REST service and WSDL is used when we create or invoke SOAP service. OWSM (Oracle Web Service Manager) policy support is also provided for REST security.

In this post, we will see how to create REST service in SOA 12c. We will also see how to test this REST service from HTTP analyzer using WADL file.

How to create REST service

To create a REST service, drag REST binding from component palette to composite. This opens the Create REST binding wizard, name your service and choose service as type. You can also added required description for this service. Now add the resource path, to add that click on green plus sign link and provide the relative path.

REST Bindings


Once you define the resource path, next step is to add operation binding. To add that go to operations bindings and click on green plus sign and choose “Add operation binding”. Once you click this, it opens another REST operation binding wizard, in that wizard provide operation name. Choose POST as HTTP verb and in request tab choose “XML” as we will receive the request in XML form. Browse the schema which we need to use for request message. Now go to response tab and repeat same steps as we did in request tab.

Add operation binding


REST Request and response msg


Now create a new BPEL, choose Define service later template. Then wire it to the above created REST service reference. Now add one receive activity inside the BPEL to receive the request, make sure you check the “Create Instance” check box in receive activity. Also add reply activity and link it to REST adapter. Add assign activity and add require logic. Once you are done with above steps, deploy your composite to SOA server. Now we will test this REST service using HTTP analyzer.

REST BPEL


How to test REST service using HTTP analyzer

As mentioned before WADL file gets generated when we deploy REST enable service to server. We will use that WADL file only to test REST enable service from HTTP analyzer. To get the WSDL file URL, go to EM console and go to your composite. Click on link as shown in below diagram to see WADL file URL. Copy this URL, we will use this URL in next step.

Get WADL file URL

Now we will use HTTP analyzer to test the REST enable service, to open the analyzer go to Jdeveloper, go to Tools then click on HTTP Analyzer. This opens new window in below pane, click on folder (Open URL) button to specify WADL file URL.


HTTP Analyzer


Once you specify the WADL URL, this opens below screen, where you can see service details. You can see one Test button for POST method, click on that button to test this service. This take you to another screen where you can specify the request parameter, provide request parameters and click on send request. This invokes the service and provides the response, you can see the response in right window.

REST service testing using HTTP Analyzer
REST Service Testing


0 comments :

Post a Comment