How to Invoke a RESTful Service
You can use Process Designer to invoke RESTful services and use them within your process.
To invoke a RESTful service
- Drag a RESTful extension activity from the Palette to the process you are building in the BPEL Editor.
- In the Properties panel open the Details tab, and set the different settings required to invoke the RESTful activity. These options are specified in the RESTful service you are invoking.
- Select the request method being used by the RESTful service: PUT, DELETE, GET, or POST.
- Use PUT to update or change the state of a resource
- Use POST to create a resource on the server
- Use GET to claim a resource
- Use DELETE to remove a resource
- Enter the path to the service. If you are using HTTPS you can verify the certificates by clicking Validate Certificates.
- In the Parameters field, click to enter any parameters required by the service.
- Open the Body tab to enter the input to the service if the request method (entered on the Details tab) is PUT or POST.
- Continue building your process, creating copy rules to specify the inputs and outputs you want.
How to create the XPath expression to get the correct data from the call to the RESTful service
You can use the ODE function ode:dom-to-string to determine that the XPath expression you create when building your project is getting the data you expect from the RESTful service.
- Add an Assign activity to your process.
- Open the Copy Rule dialog box, choose Expression in the From drop down list, and click Expression Editor.
- From the Functions panel, open the ODE node and double-click ode:dom-to-string. This inserts the function in the Expression field.
In the Variables panel, double-click RESTfulOutput.XMLResponse. This becomes the From part of your copy rule.
Click OK to close the Expression Editor.
- In the Copy Rule dialog box, specify payload.Response as the To portion of the copy rule and click OK.
- After deploying and executing the service you can see the entire XML returned from the call to the RESTful service and can make sure that the process is receiving the correct data. You may not know, when you are creating a process, the value you need. You can use ode:dom-to-string to determine which element to call in the XPath expression. In the tutorial the XPath expression is Expression[$RESTfulOutput/extensions:XMLResponse/id/text()].
To test the service
You can use a browser to test GET method types. There are third-party tools available, such as soapUI, to test the other request types.