This article has been
excerpted from book "A Programmer's Guide to ADO.NET in C#".
One more interesting and practical approach to passing an order entry is to pass
it using an XML node. SOAP enables you to pass an XML of data. This way the data
will have more useful node names such as OrderName rather than a constant
representing the order name. You won't have to worry so much about tracking
integer constants. Listing 8-7 shows InsertOrderFormNode method for taking an
XmlNode with your customer order information. You populate the new DataRow by
extracting InnerText from each ChildNode of XmlNode.
Note: You'll need to include the using System.Xml namespace to utilize
XmlNode.
Listing 8-7 web service method populating an order from XML
[WebMethod(Description = " Insert order from
XML")]
public int
InsertOrderFromNode(XmlNode aNode)
{
DataSet1 ds = new DataSet1();
oleDbDataAdapter1.SelectCommand.CommandText =
"Select * From Orders ORDER BY OredrID";
oledbDataAdapter1.Fill(ds, "Orders");
DataRow drLast =
ds.Orders.Rows[ds.Orders.Rows.Count - 1];
int LastOrderID =
Convert.ToInt32(drLast["OrderID"]);
DataSet1.OrdersRow dr = ds.Orders.NewOrdersRow();
dr.OrderID = LastOrderID + 1;
dr.OrderDate = Convert.ToDateTime(aNode["OrderDate"].InnerText);
dr.ShipName = aNode["ShipName"].InnerText;
dr.ShipAddress = aNode["ShipAddress"].InnerText;
dr.ShipCity = aNode["ShipCity"].InnerText;
dr.ShipCountry = aNode["ShipCountry"].InnerText;
dr.ShipPostalCode = aNode["ShipPostalCode"].InnerText;
ds.Orders.AddOrdersRow(dr);
oleDbDataAdapter1.Update(ds, "Orders");
return dr.OrderID;
}



omarPosted Aug 3, 2014, 2:27 AM
its help me a lot, but when the WS response with another XML, how can i decode the information