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

  1. Drag a RESTful extension activity from the Palette to the process you are building in the BPEL Editor.
    restful palette

     

  2. 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.
  3. Open the Body tab to enter the input to the service if the request method (entered on the Details tab) is PUT or POST.
  4. Continue building your process, creating copy rules to specify the inputs and outputs you want.

TIP: 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.

  1. Add an Assign activity to your process.
  2. Open the Copy Rule dialog box, choose Expression in the From drop down list, and click Expression Editor.
  3. From the Functions panel, open the ODE node and double-click ode:dom-to-string. This inserts the function in the Expression field.
  4. In the Variables panel, double-click RESTfulOutput.XMLResponse. This becomes the From part of your copy rule.

    ode to string

     

  5. Click OK to close the Expression Editor.
  6. In the Copy Rule dialog box, specify payload.Response as the To portion of the copy rule and click OK.
  7. 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.

Related Topics
Bullet Using RESTful Services with Process Designer
Bullet XPath Functions and Operators
Bullet Using the XPath Expression Editor