Inferring SharePoint 2007 Web Service Parameters

The SharePoint 2007 SDK documentation for the Beta2TR is currently lacking in details around invoking the web services. One approach you can use is to use the .NET Reflector to crack open the assembly and see what the service in question does with the parameters once recieved. In this example, let's take a look at the StartWorkflow method of the Workflow web service. The web services deployed with SharePoint are in the C:\Program Files\common files\microsoft shared\web server extensions\12\ISAPI directory, including the Workflow web service, and accessible through the _vti_bin virtual director of your SharePoint site (e.g. http:\\servername\_vti_bin\webservice.asmx). Opening the workflow.asmx file in notepad.exe reveals that the work is done in the Microsoft.Office.WorkflowSoap assembly. Two locations I've searched for SharePoint assemblies are either across all  subdirectories of C:\Program Files\common files\microsoft shared\web server extensions\12 and the GAC. In this case, the Microsoft.Office.WorkflowSoap.dll, is located in the ...\12\Config\bin so once we load it into Reflector, we can see what the StartWorkflow method really does. The current Beta2TR SDK shows the following:

public XmlNode StartWorkflow ( string item, Guid templateId, XmlNode workflowParameters )

Walking through the dissassembled code in Reflector shows that it uses the internal WorkflowImpl class to then invoke the StartWorkflow method on the SPWorkflowManager class and that the first parameter is the URL to the file on which the workflow will perform, the second is the GUID of the SPWorkflowAssociation object defining the association between the hosting document library and a workflow and, finally, the third parameter is the data that's passing into the workflow upon initialization.

While we might have been able to infer these parameters from reading the StartWorkflow methods defined in the SDK on the Workflow web service and on the SPWorkflowManager and taking an educated guess as to how they're invoked, walking through the disassembled code removes all doubt. Clearly, the same technique can be applied to any of the other web services.