Invoke Web Service Policy Example

This example illustrates a simple sequence with a single task. Once started, the activity executes the invokeWebService policy sending a ListWebServices SOAP request to the SAS BI Platform WebServiceMaker Web service. The XML for the request is provided in the input data object, and the response is stored in the output data object. The activity is assigned to sasadm as actual owner, so you can perform the task to complete, and stop the workflow.
First, define the relevant workflow and data objects. The following figure shows a simple example where the policy data objects are associated with the activity and are visible in the entire subtree:
simple process with one activity named “List BI Wed Services”
The following figure shows the process tree for the example process:
process tree for WebServiceMaker process
The data objects in the List BI Web Services activity have the following properties:
Data Object Label
Type
Value
input
XML Object
<web:ListWebServices xmlns:web="http://support.sas.com/xml/namespace /biwebservices/webservicemaker-9.2"/>
output
XML Object
None
Note: The Web service response is stored as the value for this data object during policy execution.
Both data objects use the following schema:
<schema elementFormDefault="qualified"
        targetNamespace="http://support.sas.com/xml/namespace/biwebservices/webservicemaker-9.2"
        xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:tns="http://support.sas.com/xml/namespace/biwebservices/webservicemaker-9.2"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <complexType name="StringArrayType">
      <sequence>
         <element maxOccurs="unbounded" minOccurs="1" name="string" type="string"/>
      </sequence>
   </complexType>
   <element name="MakeWebService">
      <complexType>
         <sequence>
            <element name="storedProcessPaths" type="tns:StringArrayType"/>
            <element name="serviceName" type="string"/>
            <element minOccurs="0" name="serviceNamespace" type="string"/>
            <element minOccurs="0" name="keywords" type="tns:StringArrayType"/>
            <element default="true" minOccurs="0" name="publishMetadata"
             type="boolean"/>
         </sequence>
      </complexType>
   </element>
   <element name="MakeWebServiceResponse">
      <complexType>
         <sequence>
            <element name="MakeWebServiceResult" type="string"/>
         </sequence>
      </complexType>
   </element>
   <element name="ListWebServices">
      <complexType/>
   </element>
   <element name="ListWebServicesResponse">
      <complexType>
         <sequence>
            <element name="ListWebServicesResult" type="tns:StringArrayType"/>
         </sequence>
      </complexType>
   </element>
   <element name="RemoveWebService">
      <complexType>
         <sequence>
            <element name="serviceName" type="string"/>
         </sequence>
      </complexType>
   </element>
   <element name="RemoveWebServiceResponse">
      <complexType/>
   </element>
   <element name="Fault" type="tns:Fault"/>
   <complexType name="Fault">
      <sequence>
         <element name="Exception" type="tns:Exception"/>
      </sequence>
      <attribute name="code" type="string"/>
   </complexType>
   <complexType name="Exception">
      <sequence>
         <element minOccurs="0" name="Exception" type="tns:Exception"/>
      </sequence>
      <attribute name="message" type="string"/>
   </complexType>
</schema>
Next, associate the policy definition with the activity.
Policy Parameter
Value
Event
Process Started
Action (Policy)
Invoke Web Service
Description
This policy is used to invoke a Web service function over SOAP/HTTP.
Endpoint URL
http://localhost:8080/SASBIWS/services/WebServiceMaker
Action (Web Service)
http://support.sas.com/xml/namespace/biwebservices/webservicemaker-9.2/ListWebServices
Input Data Object
WebServiceMaker/List BI Web Services/input
Output Data Object
WebServiceMaker/List BI Web Services/output
Username
sasadm@saspw
Password
password
Policy Label
Process SAS Code->Invoke SAS Code
The final response stored in the output data object is as follows:
<n:ListWebServicesResponse
 xmlns:n="http://support.sas.com/xml/namespace/biwebservices/webservicemaker-9.2"
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <n:ListWebServicesResult>
      <n:string>WebServiceMaker</n:string>
      <n:string>XMLA</n:string>
   </n:ListWebServicesResult>
</n:ListWebServicesResponse>
See the examples provided with SAS Workflow Studio for details of this example.