Calling web services

The service task collaboration diagram control allows to invoke web services from the workflow.

NewItem919

From the elements properties, invoke the service definitions edit mode to maintain the tasks parameters to call the web service.

First specify the URL of the web services wsdl file and press query. IYOPRO will access the services definition via the provided URL and provide the available actions in respective the combo box.

Select the desired action to have the input parameters populated. You can provide constant data for simple types (string, integer) directly as the respective value. If you need to provide the parameter value from a process instance variable, you need to provide a conversion logic.

In the simplest case this is a direct assignment like:

Result = MyProcessInstanceVariable

However in more complex cases like compound data types the converter allows you to populate the input parameter values as needed.

IYOPRO accepts only one output parameter from the web service. Again a converter is needed to provide the mapping of the web service result to the process instance variable. If the web service result is to be stored in a process instance variable "as-is", the convert logic again is a simple assignment:

Result = Value

Here Value is a predefined variable name containing the web service reply.

Once your web service invocation definition is complete, click on the button Define Service Call in the toolbar, to convert the definition to executable code available to the workflow engine.

Special web service functions

There a some functions specific to the web service definition

NewItem921

Show In Browser

Opens the provided URL in a new browser window. This allows a detailed inspection of the web services WSDL.

Show Generated

Code Based on the provided details to invoke the web service, IYOPRO generates python code to perform the actual invocation an parameter mapping. The generated code can be displayed with this button.

Test Service Call

Invokes the web service with the provided mappings and converters. Each step of the processing provides output. This allows to test the service call and to find potential errors in the conversion of the parameter values

Define Service Call

This button allows to "save" the generated code as workflow expression. It is required to use this function to make the web service invocation definitions available as executable code to the workflow engine.

Changes to the source code will be overwritten, if the button is clicked again.

Processing XML replies

Often web services reply with a XML document specific to the web service.

IYOPRO supports the parsing of these XML replies. The C# XML processing can be used to easily process a XML reply.

Example

Assume the reply from the web service is a XML document like this:

<?xml version="1.0" encoding="utf-16"?>
<CurrentWeather>
 <Location>Hamburg-Finkenwerder, Germany (EDHI) 53-32N 009-50E 13M</Location>
 <Time>Jun 27, 2016 - 08:50 AM EDT / 2016.06.27 1250 UTC</Time>
 <Wind> from the SSW (210 degrees) at 14 MPH (12 KT) (direction variable):0</Wind>
 <Visibility> greater than 7 mile(s):0</Visibility>
 <SkyConditions> mostly cloudy</SkyConditions>
 <Temperature> 69 F (21 C)</Temperature>
 <DewPoint> 51 F (11 C)</DewPoint>
 <RelativeHumidity> 52%</RelativeHumidity>
 <Pressure> 29.97 in. Hg (1015 hPa)</Pressure>
 <Status>Success</Status>
</CurrentWeather>

However you are only interested in the relative humidity. Using the C# XML processing one can obtain the value e.g. like this:

import clr
clr.AddReference('System.Xml')
from System.Xml import XmlDocument

xmlDoc = XmlDocument()
xmlDoc.LoadXml(Value)

nodes = xmlDoc.SelectNodes("/CurrentWeather/RelativeHumidity")
for node in nodes:
    Result = node.InnerText
    break

It is also possible and often easier to use the XML 2 Linq approach to optain the value:

import clr
clr.AddReference('System.Xml.Linq')
from System.Xml.Linq import XElement

xmlElement = XElement.Parse(Value)
Result = xmlElement.Element("RelativeHumidity").Value