Working with Web Services
|Test the script(s), processes and/or data file(s) thoroughly in a test environment, and customize them to meet the requirements of your organization before attempting to use it in a production capacity. (See the legal notice here)|
Note: The workflow sample mentioned in this article can be downloaded from the Opalis project on CodePlex: http://opalis.codeplex.com
A Workflow that demonstrates the use of the Invoke Web Services and Query XML Workflow Activities to interact with SOAP compliant Web Services.
Public Web Service Example Workflow
This example submits city, country and state information to an online Web Service. The response is in the form of XML data that will be parsed to obtain the Latitude and Longitude of the place that was submitted. Another Web Service call is made to do the reverse: provide the Latitude and Longitude and parse the returned XML data to obtain the place.
Note: This example requires Internet connectivity.
1. Invoke Public Web Service
This Workflow uses the Custom Start Activity to obtain input data using three parameters:
The Invoke Web Services Activity ‘Get Lat and Lon from Place’ subscribes to the variables from the Custom Start Activity to submit an XML Request Payload to the online Web Service using the ‘ConvertPlaceToLonLatPt’ method:
When submitting ‘Redmond’, ‘WA’, ‘USA’, the Activity returns following XML data as Published Data ‘XML Response Payload’:
<Envelope> <Body> <ConvertPlaceToLonLatPtResponse> <ConvertPlaceToLonLatPtResult> <Lon>-122.11000061035156</Lon> <Lat>47.669998168945312</Lat> </ConvertPlaceToLonLatPtResult> </ConvertPlaceToLonLatPtResponse> </Body> </Envelope>
The Query XML Activity ‘Get Lat’ subscribes to this data and uses an Xpath query ‘//Lat’ to obtain the value for Latitude:
The Query XML Activity ‘Get Lon’ subscribes to the same data and uses an Xpath query ‘//Lon’ to obtain the value for Longitude.
The Invoke Web Services Activity ‘Get Place from Lat and Lon’ subscribes to the results from both ‘Get Lat’ and ‘Get Lon’ Activities to invoke the ‘ConvertLonLatPtToNearestPlace’ method:
The Activity returns following XML data as Published Data ‘XML Response Payload’:
<Envelope> <Body> <ConvertLonLatPtToNearestPlaceResponse> <ConvertLonLatPtToNearestPlaceResult> Redmond, Washington, United States </ConvertLonLatPtToNearestPlaceResult> </ConvertLonLatPtToNearestPlaceResponse> </Body> </Envelope>
The Query XML Activity ‘Get Place’ subscribes to this data and uses an Xpath query ‘//ConvertLonLatPtToNearestPlaceResult’ to obtain the City, State and Country information:
The Send Platform Event Activity is used to display the resulting output:
Running the example Workflow
Launch the Workflow by starting it from the Operator Console or by running it using the Testing Console. When prompted, enter the appropriate values:
Check the Operator Console Event screen or the Workflow Testing Console log to see the resulting output.
Refer to the Online Help for the Invoke Web Services and Query XML Activities.
|Share this post :|