November 21 2014

Within Oracle Service Bus 12c, there are several ways to implement a pipeline as a REST service.

One approach is to REST enable an existing SOAP service. In this scenario, a pipeline is supported by both SOAP and REST based interactions. A video that provides a good overview of the required steps to implement this can be found here.

Another way is to derive it from a pipeline WSDL (REST bindings in OSB 12c are based on a WSDL document). The steps below detail the configurations required to accomplish this.

The first step is to create a pipeline that is a WSDL-based service. If the WSDL does not exist, it can be generated from a schema. To do this, select the ‘Create a WSDL’ icon in the Pipeline Service creation wizard to open the Create WSDL dialog.  Before selecting ‘Finish’, be sure the ‘Expose as a Proxy Service’ is not checked, since we will be generating a REST based proxy in a later step.

When selecting the schema to base the WSDL from, be sure to select an element type. REST services derived from WSDLs cannot be based off a schema type, only an element types are supported.

Once the WSDL is generated and the pipeline service is created, there are two options to start the REST proxy creation process. One is to right click on the pipeline to ‘Expose As REST’, the other is to right click in the Proxy Services pane in the overview editor and select ‘REST’:

 

Option One:

Option Two: 

 

 

If the second option is chosen, an additional step is required to add the operation bindings. As shown below, select to ‘REST enable component or reference’, then select the pipeline service that is to be REST enabled.

For either option, the operation bindings need to be configured within the ‘Create REST binding’ wizard.  To do this, select the operation, then select the edit operation binding:

During the creation of the WSDL, if the interface type chosen was synchronous, then the default HTTP verb will be ‘Get’ and the input parameters will be available to be edited, as shown below.

On the other hand, if a one-way interface was chosen, the HTTP verb will default to ‘Put’. The parameters are already configured when the WSDL was generated, so nothing further needs to be done.

The payload can be configured to accept or return (within the Request and Response tabs) XML, JSON, and/or URL-encoded media type.  There is also an option for no payload, if it applies. Regardless of which option is chosen, the message will be translated from/to XML before it enters the pipeline.

Also note the button to the right of the Payload specifications. When selected, it will display a sample payload, based on the selected media type.

Once the configuration of the REST proxy is complete, you will notice the creation of the WADL file in the project now. This was done automatically during this process. The REST enabled proxy is now ready for use!

About the Author

Bio

Jennie has over 25 years of information technology experience, the majority of time spent in application integration. She has broad experience in integration architecture design and implementation utilizing several integration toolsets. As an architect, she has experience developing SOA/API Governance Framework and Reference Architectures.

Join the Conversation

August 11, 2015

Hi ,

 

Is this a bug in 12c ? Please suggest the solution for this. 

 

We have couple of OSB services exposed as REST which will be consumed by REST APIs. We have proper error handling in place to handle all the error scenarios.

For below scenarios we are not able to propagate JSON error response to API :

 

1. Whenever OSB engine populates context fault ($fault) at runtime. for eg: service callout faults , validate action faults.

2. Whenever we throw error manually using Raise Error action.

 

Is this a bug in 12c ? Please suggest the solution for this.

 

### Steps to Reproduce ###

1.Expose a proxy service as REST with JSON structure for request, response and fault.

2.Use Raise Error action in message flow with custom error code and handle it in service level handler.

3.Use validate action for schema validation and raise error when validation fails.

4.Use service callout to call a SOAP web service.

5.Test REST proxy from SOAP UI , for above 3 scenarios ,xml error will be returned which doesn't obey with fault schema defined in OSB .Instead we should receive JSON error with the structure defined in fault schema.

Hi Shiva,

 

Is this a bug in 12c ? Please suggest the solution for this. 

 

We have couple of OSB services exposed as REST which will be consumed by REST APIs. We have proper error handling in place to handle all the error scenarios.

For below scenarios we are not able to propagate JSON error response to API :

 

1. Whenever OSB engine populates context fault ($fault) at runtime. for eg: service callout faults , validate action faults.

2. Whenever we throw error manually using Raise Error action.

 

Is this a bug in 12c ? Please suggest the solution for this.

 

### Steps to Reproduce ###

1.Expose a proxy service as REST with JSON structure for request, response and fault.

2.Use Raise Error action in message flow with custom error code and handle it in service level handler.

3.Use validate action for schema validation and raise error when validation fails.

4.Use service callout to call a SOAP web service.

5.Test REST proxy from SOAP UI , for above 3 scenarios ,xml error will be returned which doesn't obey with fault schema defined in OSB .Instead we should receive JSON error with the structure defined in fault schema.

August 11, 2015

Please see blog post in Oracle A-Team Chronicles (http://www.ateam-oracle.com/creating-a-mobile-optimized-rest-api-using-oracle-service-bus-part-4/) which provides a great overview on how to accomodate errors in JSON.

Rajendra
March 30, 2016

Hi can you please confirm if the following feature is supported by jdeveloper or not

I am trying to expose a wsdl based soap service as a rest with pipeline rest same as yours the only difference is that I have inline schema in the wsdl itself  that means i do not have additional xsd file. in this case in jdeveloper when exposing it as rest service i provide wsdl file instead of schema file in "rest binding" window of schema url, well jdeveloper accept here wsdl file and gives no error but when you try to check sample payload request and response json it gives no output.

is this true?

Mayank Grover
September 11, 2016

Thank you for such descriptive blog for REST to Pipeline. this helps in exposing same pc of code as SOAP and REST both :)

 

keep posting.....

 

Thanks again.

AB
September 12, 2016

Hi Jennie, Thanks for explaining new Rest feature in 12c. Is it possible to expose both SOAP and REST service at the same time?? both linked with the same OSB pipeline pair??

Regards,

AB

 

Enter your first name. It will only be used to display with your comment.
Enter your email. This will be used to validate you as a real user but will NOT be displayed with the comment.
By submitting this form, you accept the Mollom privacy policy.