[英]wcf throwing error on android client post
I am getting this message when executing a client post from an android device (evo 4g). 从android设备(evo 4g)执行客户端发布时,我收到此消息。
--Data at the root level is invalid. -根级别的数据无效。 Line 1, position 1.: 1
第1行,位置1.:1
This web service is working for a microsoft client written in c#. 此Web服务适用于用C#编写的Microsoft客户端。 Here is the Service Contract--
这是服务合同-
[OperationContract(Name="simpleGet")] [WebInvoke(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "resource/{username}", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare)] [OperationContract(Name =“ simpleGet”)] [WebInvoke(ResponseFormat = WebMessageFormat.Xml,UriTemplate =“ resource / {username}”,方法=“ POST”,BodyStyle = WebMessageBodyStyle.Bare)]
string GetData(string username);
and here is the android client code-- 这是android客户端代码-
HttpClient httpclient = new DefaultHttpClient(); HttpClient httpclient = new DefaultHttpClient(); String url = "http://dev.journalr12.com/RestService.svc/resource/yegua";
字符串url =“ http://dev.journalr12.com/RestService.svc/resource/yegua”;
HttpPost httppost = new HttpPost(url);
httppost.addHeader("userpass", "20,yeguacreek,date,10-1-10,none");
String result="";
// Execute the request
HttpResponse response;
String xml = entryXML.sqlXML(entryData) ;
StringEntity se = new StringEntity(xml);
se.setContentType("text/xml");
se.setContentEncoding("utf8");
httppost.setEntity(se);
response = httpclient.execute(httppost);
// Get hold of the response entity
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
result= convertStreamToString(instream);
String a = "";
}
return result;
After building the microsoft client and experiencing the different exceptions that would get thrown, I don't think this is making it to the getData function. 在构建了Microsoft客户端并经历了将引发的不同异常之后,我认为这不会使它成为getData函数。 I would love some suggestions.
我希望有一些建议。
This problem was caused by the xml stream not able to be read by a DataSet read operation. 造成此问题的原因是DataSet读取操作无法读取xml流。 I thought I could put together the xml in the same way the Microsoft client DataSet did in the writexml operation.
我以为我可以像Microsoft客户端DataSet在writexml操作中一样整理xml。 Linq to xml works much better!
Linq to xml的效果更好!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.