- Create a custom list "Power Snippets"
- Add a multiple line plain text column, perhaps 60 lines, "PSScript"
- Define any other list to attach the workflow (Title, Result as Rich Text)
- Add your snippets to the list (e.g. my Get-WebServiceProxy script (Requirements for this script: Windows SDK (wsdl.exe) and .NET 3.5. )
- Use the snippet in SharePoint Designer. Add the "Execute PowerShell Activity to your SPD Workflow. Define a workflow variable named "result" type of text to store the result of the web service request. Insert the following script:
- The [%Power Snippets:PSScript%] is a lookup to our Get-WebServiceProxy script snippet. The lookup makes the Get-WebServiceProxy function available to our script. The lookup is something like an old school PHP-include ;-)
- The script bellow the lookup generates a proxy for the SharePoint Lists.asmx webservice, call the GetListCollection method, generates from the response an HTML string containing a bullet list.
- In the next step we set the "Result" column to the "result" variable we filled before with PowerActivity.
Another way to call a web service with the PowerActivity would be to create the proxy with or Visual Studio wsdl.exe, compile and deploy the assembly to the global assembly cache of the server. Now you can load the assembly in PowerShell like [System.Reflection.Assembly]::Load... and instantiate the proxy New-Object -TypeName... This solution is faster and you don't need the WinSDK on the server.