With this custom SharePoint Designer Action you are able to call web services from SPD workflows. The action is included in my Advanced SharePoint Designer 2010 Workflow Actions release on CodePlex. The source code is available too. Let’s go!
1. Add “Call a Web Service” Action to a SharePoint Designer 2010 Workflow
2. Configure the Action
- URL: The URL of the Web Service
- SOAP Version: The SOAP Version of the request (1.1. or 1.2)
- Action: The SOAP Action for the request
- SOAP Request Envelope: The SOAP Envelope for the request (http://schemas.xmlsoap.org/soap/envelope/). The request will be UTF8 encoded. You can use two special tokens in the request that can not be inserted via the UI: [WebUrl] and [WorkflowInstanceId].
- User: The user name for requests that needs authentication e.g. “Contoso\Administrator”. Instead of using user name and password you can use Secure Store Credentials.
- Password: The password for the user. Unfortunately there isn’t a masked text box :-( You could either specify the password in clear text or encrypted like described here: Encrypt Passwords for SharePoint Designer Workflow Actions
- AppId: The The Secure Store Application ID. The Secure Store App have to define 2 Fields. One of type “User Name” and one of type “Password”. The Field Name doesn’t matter, important is the Field Type! You have to map the credentials of the SharePoint Service Accounts (AppPool/owstimer.exe). The secure store option will only works with SharePoint Server not with Foundation!
3. ExampleCreate a new List with the SharePoint Lists.asmx Web Service.
Configuration of “Call Web Service”
- URL: http://[siteurl]/_vti_bin/Lists.asmx
- SOAP Version: SOAP 1.2
- SOAPAction: not needed for SOAP 1.2
- Response: The response will be stored in the variable “Response”
- User: empty
- Password: empty
- Secure Store AppId: Instead of using user name and password we use the secure store app with the ID test. The app defines “User Name” and Password. The format of the user name for windows user should be “Domain\username”.
- SOAP Request 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>
Next we extract the ID of the new list.from the resulting XML. To do this you can use the “Query XML” action that is also included in the package.
Configuration of “Query XML”
- XML: The XML of the SOAP-Reponse that has been stored in the Variabe “Response”
- XPath: //*[local-name()='List']/@ID
- Output: The output (List Id) will be stored in the Variable “ListID”
Write the “ListID” to the history log
download | documentation