At this write I'll try to show you how to create and test a simple Rest service in Oracle SOA Suite environment, with a small validate data example.Using Restful approach we can use raw xml or even no xml data instead of using Soap messages in Soap based services.It is sometimes painful to deal with the overengineered Soap services.At that time the Restful based services come to rescue to develop faster web services and to decrease response time of the services.Of course this will bring some extra effort at some points, since Rest doesn't have some builtin capabilities of Soap.For example, although there is an attempt to define Restful services with wadl(web application description language), it is not yet well understood and widely used like wsdl(web services description language).However its more eaiser to develop Restful services in Oracle SOA Suite environment.
Let's start with creating the bpel process. There will be some differences on creating and testing the Restful service because of the reasons we mentioned above.
Create the Bpel Process:
Create a Bpel process with "Define Service Later" template in a Soa project in the composite page.
Figure 1
Create a xsd file to use in our example.We'll use Xml data as input and output of the Restful service.
Figure 2
In Figure 2, you can see we have two input variables to validate, one string and one date.Now, open the composite page and create a REST service in the exposed services part as in Figure 3.
Figure 3
On the "Create Rest binding" page, rename the service, enter a resource path and click on the plus sign on the Operation bindings part.
Figure 4
On the next page, enter the operation name, choose the Http Verb as POST (Since we'll use xml input) and for the request and response choose the process and processResponse elements of our xsd we just created above.See in Figure 5 and 6.
Figure 5
Figure 6
The final screen should look like the following, just press OK.
Figure 7
Now, go to the composite page and link the REST service with the Bpel process, choosing the transaction as "required" like in Figure 8.
Figure 8
Built the Details of Bpel Process:
Go to the Bpel editor, and drag and drop a Reveice component.
Figure 9
On the "Edit receive" page, check "Create Instance" and create an input variable by clicking the green plus sign.See in Figure 10.
Figure 10
Similarly create the output variable like in Figure 11.
Figure 11
You can now drag and drop a "Validate" activity after the receiveInput component and the final Figure will be like below.
Figure 12
Open the "Edit validate" page by double clicking the validate activity and choose the input to validate.
Figure 13
Our aim is to get a fault if there is an error while validating variables.So we'll use catchAll activity with the help of a scope activity that wraps the validate component.If there is an error in the variables validation we'll catch the Rest fault.See in Figure 14.
Figure 14
Next, drag and drop two assign activities after validate and catchAll respectively to set true or false to the return value which is a boolean.See in Figure 15.
Figure 15
Figure 16
In Figure 16 we see the whole Bpel process completed.
Test the Restful Service:
Testing a Restful service is different than testing a Soap based service.First deploy the project after starting the integrated weblogic server.
Figure 17
Now, we have to go to the enterprise manager and obtain the wadl of our service.Go to the http://localhost:7101/em, click on the project under soa-infra->Default, then click on the image that two after the "Settings..." button.Copy the wadl address that you see in Figure 18 and 19.
Figure 18
Figure 19
We can now go to the Jdeveloper again, and choose Tools->HTTP Analyzer.
Figure 20
Click on "Open Url" on the opened page and paste the wadl you just copied.
Figure 21
You can see wadl of your service in Jdeveloper now like in Figure 22.Click on Test button.
Figure 22
Enter a valid and non-valid date value in to the second parameter and see the result like in Figure 23 and 24.
Figure 23
Figure 24
Conclusion:
Today, I explained the usage of Restful services in SOA Suite with a validate data example.You can sometimes choose to use the lightweight Restful approach.However, you need to develop some builtin capabilities by hand by this approach that are already implemented in Soap based approach until Restful approach become more popular and engineered as Soap based approach.
You can download the source code from here.