Difference between revisions of "Incoming Web Service Requests Tutorial"

From PresenceWiki
Jump to: navigation, search
(Troubleshooting)
(1: Creating the Task)
 
(4 intermediate revisions by the same user not shown)
Line 20: Line 20:
 
Here is a view of the Task, which can be downloaded [http://www.international-presence.com/wikidocs/samples/Web_Service_Tutorial.zip here]:
 
Here is a view of the Task, which can be downloaded [http://www.international-presence.com/wikidocs/samples/Web_Service_Tutorial.zip here]:
  
http://www.international-presence.com/wikidocs/images/calc_circumference_taskview.png
+
 
 +
[[file:calc_circumference_taskview.png]]
  
 
=== 2: Creating the Web Service ===
 
=== 2: Creating the Web Service ===
Line 27: Line 28:
  
  
http://www.international-presence.com/wikidocs/images/ws_tutorial_1.png
+
[[file:ws_tutorial_1.png]]
  
 
* The alias represents the name of the Operation that will be called and is auto-generated based on the Task name. Feel free to change this, or leave it as it is.
 
* The alias represents the name of the Operation that will be called and is auto-generated based on the Task name. Feel free to change this, or leave it as it is.
Line 39: Line 40:
 
* Click the "Get Task Parameters" button to map the incoming and outgoing variables to Web service parameters:
 
* Click the "Get Task Parameters" button to map the incoming and outgoing variables to Web service parameters:
  
http://www.international-presence.com/wikidocs/images/ws_tutorial_2.png
+
[[file:ws_tutorial_2.png]]
  
 
Click okay to return to the Web Services properties screen. You can double click on the parameters to set the data type (which should be "double" for both parameters) and to add documentation.
 
Click okay to return to the Web Services properties screen. You can double click on the parameters to set the data type (which should be "double" for both parameters) and to add documentation.
Line 63: Line 64:
 
Click "Okay" and after a small delay you should see a web service tree like the following, which describes the service, port and operations available for this WSDL:
 
Click "Okay" and after a small delay you should see a web service tree like the following, which describes the service, port and operations available for this WSDL:
  
http://www.international-presence.com/wikidocs/images/ws_tutorial_3.png
+
[[file:ws_tutorial_3.png]]
  
 
Double click our Operation (CalculateCircumferenceWS) to specify that this is the operation we want to call, then click the "Input" tab. Select the "radius" element - which is bound to the ${radius} variable in our Web Service Task - and enter a value in the text field.
 
Double click our Operation (CalculateCircumferenceWS) to specify that this is the operation we want to call, then click the "Input" tab. Select the "radius" element - which is bound to the ${radius} variable in our Web Service Task - and enter a value in the text field.
Line 77: Line 78:
 
=== Troubleshooting ===
 
=== Troubleshooting ===
  
If you have any queries or problems following or implementing this tutorial we'd be pleased to assist. Please drop an email to [mailto:pryor@presencebpm.com Matt Pryor].
+
If you have any queries or problems following or implementing this tutorial we'd be pleased to assist. Please drop an email to [mailto:support@presencebpm.com Support].

Latest revision as of 09:16, 20 August 2015

Tutorial Pages > Incoming Web Service Requests Tutorial

This document gives a step-by-step guide to exposing a Presence Task as a Web Service.

1: Creating the Task

The first step is to create our Task. For the purposes of this demonstration we will create a Web Service that calculates the circumference of a circle given the radius. The Task to do this is very simple and comprises of:

  1. Start of Task Node
  2. Require Variable Node - ${radius}
  3. Set Variable Node - ${circumference}
  4. End of Task Node

The variable ${radius} will be an incoming parameter and ${circumference} will be an outgoing parameter.

To calculate the circumference we call the following function in our Set Variable Node (3):

&eval {"2 * ${radius} * PI"}

Here is a view of the Task, which can be downloaded here:


Calc circumference taskview.png

2: Creating the Web Service

Once a Task is created exposing it as a Web Service is extremely straight forward. First launch the Live Tasks Queue. Click on the third tab (Web Service Processes) and then drag the Task into the main table. You'll then be presented with the Web Service Properties Dialog:


Ws tutorial 1.png

  • The alias represents the name of the Operation that will be called and is auto-generated based on the Task name. Feel free to change this, or leave it as it is.
  • It's always a good idea to add documentation to the Web Service itself and to any parameters.
  • Make sure "Task is active" is checked and that "One Way" is not checked.
  • Copy the WSDL location to your clipboard as you will need this later when calling the Web Service.
  • Click the "Get Task Parameters" button to map the incoming and outgoing variables to Web service parameters:

Ws tutorial 2.png

Click okay to return to the Web Services properties screen. You can double click on the parameters to set the data type (which should be "double" for both parameters) and to add documentation.

This should be all you need to do - click Okay and you should see your Task in the Web Services list.

That's it!

3: Testing your Web Service

Now to test out our newly created Web Service. Create another new Task and drag a Web Service Call Node into the Task canvas. The first thing we need to do is set the WSDL location which you copied from the Web Service properties dialog. Click the "New" button, select "On the Internet" and enter the URL. This will be of the form:

http://[servername]:[port]/[wsdl_location]

Where [servername] is the hostname of a machine running the Presence HTTP Server, [port] is the port it is listening on - this is 80 by default unless you have changed it in the http.config file, and [wsdl_location] is the WSDL document location displayed on the Web Service Properties dialog.

So, here at the Presence development labs we have a server named "presenceserver" and this is the WSDL location we used for this project:

http://presenceserver/Presence/Web_Service_Tutorial.wsdl (don't click this - it won't work).

Note that the port is not included in the URL as 80 is the default port for HTTP requests and is therefore unnecessary.

Click "Okay" and after a small delay you should see a web service tree like the following, which describes the service, port and operations available for this WSDL:

Ws tutorial 3.png

Double click our Operation (CalculateCircumferenceWS) to specify that this is the operation we want to call, then click the "Input" tab. Select the "radius" element - which is bound to the ${radius} variable in our Web Service Task - and enter a value in the text field.

Click the "Output" tab and drag the <circumference> tag into the list on the right.

Finally, click the "Test" tab and then click the "Test" button, and you should see the result of your called operation in the table below. You can check the XML that was sent to and received from the server by clicking the "Input Document" and "Output Document" tabs.

Related Documents

SOAP

Troubleshooting

If you have any queries or problems following or implementing this tutorial we'd be pleased to assist. Please drop an email to Support.