public string convertRequestToXML(servicerequest servicerequest) { StringWriter textWriter = new StringWriter(); XmlSerializer serializer = new XmlSerializer(servicerequest.GetType()); serializer.Serialize(textWriter, servicerequest); string payload = textWriter.ToString(); Debug.WriteLine("payload [" + payload + "]"); return payload; }
private static servicerequest createLookItemRequest(string productcode) { servicerequest servicerequest = new servicerequest(); servicerequest.ItemElementName = ItemChoiceType.productrequest; servicerequest.Item = new producttype(); ((producttype)servicerequest.Item).productcode = productcode; StringWriter textWriter = new StringWriter(); XmlSerializer serializer = new XmlSerializer(servicerequest.GetType()); serializer.Serialize(textWriter, servicerequest); string payload = textWriter.ToString(); Debug.WriteLine("payload [" + payload + "]"); return servicerequest; }
private static servicerequest createAddItemRequest(string productcode, int quantitysold, decimal pricesold) { servicerequest servicerequest = new servicerequest(); servicerequest.ItemElementName = ItemChoiceType.productrequest; servicerequest.Item = new producttype(); ((producttype)servicerequest.Item).productcode = productcode; ((producttype)servicerequest.Item).quantitysold = quantitysold; ((producttype)servicerequest.Item).quantitysoldSpecified = true; ((producttype)servicerequest.Item).pricesold = pricesold; ((producttype)servicerequest.Item).pricesoldSpecified = true; StringWriter textWriter = new StringWriter(); XmlSerializer serializer = new XmlSerializer(servicerequest.GetType()); serializer.Serialize(textWriter, servicerequest); string payload = textWriter.ToString(); Debug.WriteLine("payload [" + payload + "]"); return servicerequest; }