First let me tell you that in order to use the list's web service in a subsite you have to add ?WSDL to the URI of the web service. Example: http://server/subsite/_vti_bin/Lists.asmx?WSDL. If you do not append ?WSDL you will not receive any error, but will operate with the web service of the top level site instead of the subsite and you will not find your list in the subsite. We will use a Contacts List template to save our contacts. It let us to synchronize with MS Outlook 2007 in order to view these contacts in out Address Book. You can see a method to accomplish it: { PCM.Lists list = new PCM.Lists(); list.Credentials = new System.Net.NetworkCredential("user", "P@$$w0rd"); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); elBatch.SetAttribute("OnError", "Continue"); elBatch.SetAttribute("ListVersion", "1"); el1.SetAttribute("ID", "1"); el1.SetAttribute("Cmd", "New"); field1.SetAttribute("Name", "Company"); field1.InnerText = company; field2.SetAttribute("Name", "WorkAddress"); field2.InnerText = address; field3.SetAttribute("Name", "FirstName"); field3.InnerText = name; field4.SetAttribute("Name", "Title"); field4.InnerText = surname; field5.SetAttribute("Name", "Email"); field5.InnerText = email; field6.SetAttribute("Name", "WorkPhone"); field6.InnerText = phone; field7.SetAttribute("Name", "WorkCountry"); field7.InnerText = language; elBatch.AppendChild(el1); el1.AppendChild(field1); el1.AppendChild(field2); el1.AppendChild(field3); el1.AppendChild(field4); el1.AppendChild(field5); el1.AppendChild(field6); el1.AppendChild(field7); } Note: PCM is a Web Reference to our Lists.asmx web services. Now you may synchronize the list with Outlook. Related Links:
static
bool insertContact(string company, string address, string name, string surname, string email, string phone, string language)
XmlElement elBatch = doc.CreateElement("Batch");
XmlElement el1 = doc.CreateElement("Method");
XmlElement field1 = doc.CreateElement("Field");
XmlElement field2 = doc.CreateElement("Field");
XmlElement field3 = doc.CreateElement("Field");
XmlElement field4 = doc.CreateElement("Field");
XmlElement field5 = doc.CreateElement("Field");
XmlElement field6 = doc.CreateElement("Field");
XmlElement field7 = doc.CreateElement("Field");
XmlNode rNode = list.UpdateListItems("Contacts", elBatch);
return
true;
http://shlakapau.spaces.live.com/blog/cns!72ADBFE6717AFAF!107.entry
Saturday, March 31, 2007
Inserting a contact item in a Contacts Lists in a subsite through the UpdateListItems web service
Publicado por Àlex en 8:34 PM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment