【发布时间】:2012-02-15 11:34:39
【问题描述】:
这是用 C# 编写的用于发布 XML 文档元素的代码
XmlString = @"<WOITEMS><WOITEM ACTION='I'>" + TransData + "</WOITEM></WOITEMS>";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(XmlString);
saveRegisterItems(xmlDoc.DocumentElement);
saveRegisterItems 是一个 WCF 服务方法,它接收一个文档元素作为它的参数。如何在 Android 中使用 HttpPOST 做到这一点?我尝试了下面的代码。但是,它不起作用。
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);
我得到 response.getStatusLine() 为“HTTP/1.1 200 OK”,但是它没有在服务器中更新。我认为,传递一个 XML 文档元素就可以了。请帮忙
【问题讨论】: