Tuesday, March 10, 2009

Web service call to fetch orders from Commerce Server 2007

Here is an exmaple of a web service call to search for orders in Commerce Server:


System.Xml.XmlDocument searchClause = new System.Xml.XmlDocument();
searchClause.LoadXml(@"<CLAUSE OPER=""equal"" xmlns=""http://schemas.microsoft.com/CommerceServer/2004/02/Expressions"">
<PROPERTY ID=""PurchaseOrder.Status"" MULTIVAL=""false"" TYPE=""String"" />
<IMMED-VAL TYPE=""String"">
<VALUE>NewOrder</VALUE>
</IMMED-VAL>
</CLAUSE>");
SearchOptions searchOptions = null;
OrderService os = new OrderService();
os.Credentials = new System.Net.NetworkCredential("User", "Password", "domain");
DataSet ds = os.GetAllowedStatus();
ds = os.SearchPurchaseOrders((System.Xml.XmlElement)searchClause.FirstChild, searchOptions);