We discussed about REST services and also saw how to create REST services in SOA 12c in previous post. Click here to read that post, if you didn’t read that already. As we saw in that post, WADL file gets generated when we deploy REST service to server and we use that WADL file to test that REST service.
In this post, we will see how to invoke REST service from SOA composite in 12c. To invoke the REST service we use the WADL file of REST service. In earlier version of SOA we use HTTP bindings to invoke REST service but in this version we use REST bindings to invoke REST services. REST bindings also provide JSON support in this version.
We have created a sample composite and added a BPEL to it. We will add reference to the composite to invoke REST service. To add reference to composite file, drag REST bindings which you can find under component palette. REST binding was not part of SOA 11g, this is newly introduced in SOA 12c. Once you drag the REST binding to composite file, it opens another wizard where we fill required information to add REST service reference.
Provide REST service reference name and make sure type is selected as Reference in drop down list. Now we will add required operation of REST service and we will use WADL file for that. To do that click on green plus button in Operation Bindings section and choose “Add operation based on WADL service”.
Once you click on above option, it opens another wizard window where we need to choose the REST service WADL file. Click on Application server and choose WADL file under SOA folder. We choose the integrated Weblogic server as we use this server, you can choose standalone server if you are using that server.
Once you choose the WADL file, you can see all the required information like resource path, operation, http verb gets filled automatically in create REST binding wizard. Click on ok, then it ask to maintain local copy of the files, check all checkboxes and click ok. This will add required REST service reference to your composite, now wire the REST reference to BPEL process, your final composite should look like below.
Now compile this service and deploy it to the server. Now we either test this service from HTTP analyzer or from EM console. To test it from HTTP analyzer, go to application server connection and choose Integrated Weblogic server connection, expand till SOA folder and go to above deployed service WSDL file , right click on that and test it. This opens HTTP analyzer window where we can provide required input and see the response.
To test it from EM console, go to EM console and in the left pane, open the above deployed composite and click on test. Fill request parameters and test the service. You can see success response in response tab. Open the instance and see the flow, in the flow you can that BPEL successfully invoked the REST service.