(c) 2004 Visual Studio Magazine 
Fawcette Technical Publications

XML	Generate SOAP Request/Response Messages
Listing 1	The Web Services Definition Language (WSDL) document for the Lists Web service's GetListItems Web method defines these SOAP request and response messages, which return the rows from a SharePoint list of Northwind customers. VB.NET procedural code transforms the response message's payload to populate a DataTable that serves as the DataGrid's RecordSource.

<!-- SOAP request message -->
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope 
		xmlns:soap="http://schemas.xmlsoap.org/
			soap/envelope/" 
		xmlns:xsi="http://www.w3.org/2001/
			XMLSchema-instance" 
		xmlns:xsd= 
			"http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetListItems 
				xmlns="http://schemas.microsoft.com/
					sharepoint/soap/">
			<listName>{418D6B7D-27BD-48F6-A0A1-
					C851FBBEDFE4}</listName>
			<viewName />
			<rowLimit>100</rowLimit>
		</GetListItems>
	</soap:Body>
</soap:Envelope>

<!-- SOAP response message -->
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope 
		xmlns:soap= 
			"http://schemas.xmlsoap.org/soap/
			envelope/" 
		xmlns:xsi="http://www.w3.org/2001/
			XMLSchema-instance" 
		xmlns:xsd= 
			"http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetListItemsResponse 
				xmlns="http://schemas.microsoft.com/
					sharepoint/soap/">
			<GetListItemsResult>
				<listitems 
				 xmlns:s="uuid:BDC6E3F0-6DA3-11d1-
					A2A3-00AA00C14882"
				 xmlns:dt="uuid:C2F41010-65B3-11d1-
					A29F-00AA00C14882"
				 xmlns:rs="urn:schemas-microsoft-
					com:rowset" 
				 xmlns:z="#RowsetSchema">
					<rs:data ItemCount="91">
						<z:row ows_CustomerID="ALFKI" 
							ows_CompanyName="Alfreds 
								Futterkiste" 
							ows_ContactName="Maria 
								Anders" 
							ows_ContactTitle="Sales 
								Representative" 
							ows_Address="Obere Str. 
								57" 
							ows_City="Berlin" 
							ows_PostalCode="12209" 
							ows_Country="Germany" 
							ows_Phone="030-0074321" 
							ows_Fax="030-0076545" 
							ows_ID="1" ows_owshidden-
								version="10" />
	<!-- Remaining items removed for brevity -->
					</rs:data>
				</listitems>
			</GetListItemsResult>
		</GetListItemsResponse>
	</soap:Body>
</soap:Envelope>

XML	Represent Updates with DiffGrams
Listing 2	The DataGrid generates this ADO.NET DiffGram when you alter one customer record and insert a record for a new customer. Procedural code in the ListsWSUpdate project transforms the DiffGram to Listing 3's CAML batch statement.

<diffgr:diffgram 
		xmlns:msdata="urn:schemas-microsoft-
			com:xml-msdata" 
		xmlns:diffgr="urn:schemas-microsoft-
			com:xml-diffgram-v1">
	<NewDataSet>
		<Items diffgr:id="Items1" 
				msdata:rowOrder="0" 
				diffgr:hasChanges="modified">
			<ID>1</ID>
			<CustomerID>ALFKI</CustomerID>
			<CompanyName>Alfreds 
				Futterkiste</CompanyName>
			<ContactName>Maria Anders</ContactName>
			<ContactTitle>Sales 
				Representative</ContactTitle>
			<Address>Obere Str. 57</Address>
			<City>Berlin</City>
			<PostalCode>12209</PostalCode>
			<Country>Germany</Country>
			<Phone>030-0074321</Phone>
			<Fax>030-0076545</Fax>
		</Items>
	</NewDataSet>
	<diffgr:before>
		<Items diffgr:id="Items1" 
				msdata:rowOrder="0">
			<ID>1</ID>
			<CustomerID>ALFKI</CustomerID>
			<CompanyName>Alfreds 
				Futterkiste</CompanyName>
			<ContactName>Maria Anders-
				Benson</ContactName>
			<ContactTitle>Sales 
				Representative</ContactTitle>
			<Address>Obere Str. 57</Address>
			<City>Berlin</City>
			<PostalCode>12209</PostalCode>
			<Country>Germany</Country>
			<Phone>030-0074321</Phone>
			<Fax>030-0076545</Fax>
		</Items>
		<Items diffgr:id="Items2" 
				msdata:rowOrder="1">
			<ID>108</ID>
			<CustomerID>BOGUS</CustomerID>
			<CompanyName>Bogus 
				Company</CompanyName>
			<ContactName>Joe Bogus</ContactName>
			<ContactTitle>Proprietor</ContactTitle>
		</Items>
	</diffgr:before>
</diffgr:diffgram>

XML	Transform a DiffGram to CAML
Listing 3	Use CAML Batch documents to make multiple updates, inserts, deletes or all three to SharePoint lists. This CAML statement reverses the update and insert made by Listing 2's DiffGram. Specify the OnError attribute value as Continue to disregard data-consistency errors that might occur during update operations.

<Batch OnError='Continue' ListVersion='1'>
	<Method ID='Items1' Cmd='Update'>
		<Field Name='ID'>1</Field>
		<Field Name='CustomerID'>ALFKI</Field>
		<Field Name='CompanyName'>Alfreds 
			Futterkiste</Field>
		<Field Name='ContactName'>Maria 
			Anders</Field>
		<Field Name='ContactTitle'>Sales 
			Representative</Field>
		<Field Name='Address'>Obere Str. 57</Field>
		<Field Name='City'>Berlin</Field>
		<Field Name='PostalCode'>12209</Field>
		<Field Name='Country'>Germany</Field>
		<Field Name='Phone'>030-0074321</Field>
		<Field Name='Fax'>030-0076545</Field>
	</Method>
	<Method ID='Items2' Cmd='Delete'>
		<Field Name='ID'>108</Field>
	</Method>
</Batch>

XML	Respond to Error Codes
Listing 4	Sending a CAML Batch update document returns a SOAP response message that confirms the modified values and an ErrorCode element value of 0 for a successful update. Inserts return only the ErrorCode value. You must test the response document for non-zero error codes to display a client-side error message, invoke code to handle the error, or both.

<Results xmlns="http://schemas.microsoft.com/ 
	sharepoint/soap/">
	<Result ID="Items1,Update">
		<ErrorCode>0</ErrorCode>
		<z:row ows_ID="1" ows_Modified=
			"2003-10-02 13:42:19" 
			ows_Created="2003-03-21 12:25:11" 
			ows_Author="1;#OAKLEAF\administrator" 
			ows_Editor="1;#OAKLEAF\administrator" 
			ows_owshiddenversion="16" 
			ows_Attachments="0" 
			ows__ModerationStatus="0" 
			ows_SelectTitle="1" 
			ows_Order="100.000000000000" 
			ows_GUID="{BB0EE4D1-B3D2-4A51-BE7B-
				F8603F772492}" 
			ows_CustomerID="ALFKI" 
			ows_CompanyName="Alfreds Futterkiste" 
			ows_ContactName="Maria Anders" 
			ows_ContactTitle="Sales Representative" 
			ows_Address="Obere Str. 57" 
			ows_City="Berlin" 
			ows_PostalCode="12209" 
			ows_Country="Germany" 
			ows_Phone="030-0074321" 
			ows_Fax="030-0076545" 
			xmlns:z="#RowsetSchema" />
	</Result>
	<Result ID="Items2,Delete">
		<ErrorCode>0</ErrorCode>
	</Result>
</Results>

