“iLSP” – is the abbreviation for iLove SharePoint.
The “Call a WebService” workflow action is included in the iLSP -SharePoint Designer Actions 1.0 release. Installation see readme.txt.
The action supports SOAP 1.1, SOAP 1.2, basic and windows authentication.
Let’s go and call a built-in SharePoint web service – Lists.asmx and create a new List with the AddList operation.
- Bring up SharePoint Designer and create a new workflow on an list with a “Title” and “Response” (Multiple lines of text – plain text) column.
- Add the “Call a Web Service” action from the “iLove SharePoint” category
- Configure the action as follows:
- URL: http://[siteurl]/_vti_bin/Lists.asmx
- SOAP Version: SOAP 1.2
- SOAPAction: not needed for SOAP 1.2
- Envelope:
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<AddList xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>[%MyList:Title%]</listName>
<description>Created by iLSP action</description>
<templateID>100</templateID>
</AddList>
</soap12:Body>
</soap12:Envelope>
You can copy the SOAP 1.2 example request from http://[siteurl]/_vti_bin/Lists.asmx?op=AddList
- For the <listName> insert a reference to the current item’s title.
- As <description> enter “Created by iLSP action”
- Set the <templateID> to “100” = custom list
- Response: create a new string workflow variable named “response” and assign it. The action will fill the variable with the response from web service call (xml string).
- User: leave empty. Empty user = use default credentials.
- Password: leave empty
Now the “Call a WebService” action is configured.
To check the response, we will write it in the “Response” column of the item using the built-in “Set field in current item” action. Set field to “Response” and “Value” to the above defined workflow variable “response”
Try it – Start the workflow on an item
The response:
The new list:
Because the raw response isn’t very useful, we now parse it using iLSP “Query XML” action. Place the action between the “Call a WebService” and the “Set field in current item” action.
- Add the “Query XML” action to the workflow
- Configure the “Query XML” action
- Input: choose the above defined workflow variable “response”
- XPath: “//*[local-name()='List']/@ID”
- You can use any valid XPath expression e.g. count(//*). Is the expression result is a single node it will write the node’s inner XML to the result variable. Is the result a node collection, it will merge all the node’s inner XML separated by an semicolon into the result variable. You should identify the node by the local name, because you can’t use xml namespaces.
- Result: Create a new string workflow variable named “ListID” and assign it.
The “Query XML” action is now configured
Now modify the “Set field in current item” action so that the response column is set to the ListID variable.
Start the workflow again
Result:
THE END