This is the code done in C# for posting an XML Document Element
XmlString = @"<WOITEMS><WOITEM ACTION='I'>" + TransData + "</WOITEM></WOITEMS>";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(XmlString);
saveRegisterItems(xmlDoc.DocumentElement);
saveRegisterItems is a WCF service method which receives a Document Element as it’s parameter. How can I do that in Android using HttpPOST? I tried the below code. But, it doesn’t work.
HttpResponse response = null;
String myUrl = "http://"+Constants.strURL+"/ServiceOrders.svc/SaveRegisterItems";
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(myUrl);
StringEntity se = new StringEntity(XmlString, HTTP.UTF_8);
se.setContentType("text/xml");
httpPost.setHeader("Content-Type", "application/soap+xml;charset=UTF-8");
httpPost.setEntity(se);
I get response.getStatusLine() as “HTTP/1.1 200 OK” but, it’s not updated in the server. I think, passing a XML Document Element will do it. Please Help
I got the solution when I changed the second parameter of httpPost.setHeader() method. It should like this.
I got proper response by giving EntityUtils.toString(entity).