0
votes

I am getting this message when executing a client post from an android device (evo 4g).

--Data at the root level is invalid. Line 1, position 1.: 1

This web service is working for a microsoft client written in c#. Here is the Service Contract--

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

string GetData(string username);

and here is the android client code--

HttpClient httpclient = new DefaultHttpClient(); String 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. I would love some suggestions.

1

1 Answers

0
votes

This problem was caused by the xml stream not able to be read by a DataSet read operation. I thought I could put together the xml in the same way the Microsoft client DataSet did in the writexml operation. Linq to xml works much better!