【问题标题】:wcf throwing error on android client postwcf在android客户端帖子上抛出错误
【发布时间】:2011-08-07 20:23:16
【问题描述】:

我在从 android 设备 (evo 4g) 执行客户端发布时收到此消息。

--根级别的数据无效。第 1 行,位置 1.: 1

此 Web 服务适用于用 c# 编写的 Microsoft 客户端。这是服务合同--

[OperationContract(Name="simpleGet")] [WebInvoke(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "resource/{username}", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare)]

string GetData(string username);

这里是安卓客户端代码--

HttpClient httpclient = new DefaultHttpClient(); 字符串 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;

在构建 microsoft 客户端并遇到可能引发的不同异常之后,我认为这不会导致 getData 函数。我会喜欢一些建议。

【问题讨论】:

    标签: c# android wcf


    【解决方案1】:

    此问题是由 DataSet 读取操作无法读取 xml 流引起的。我想我可以像 Microsoft 客户端 DataSet 在 writexml 操作中所做的那样将 xml 放在一起。 Linq to xml 效果更好!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-12-24
      • 1970-01-01
      • 1970-01-01
      • 2011-12-27
      • 2015-06-11
      • 1970-01-01
      • 2017-12-13
      相关资源
      最近更新 更多