如何在Android上发布XML(org.w3c.dom.Document)和字符串(时间戳)?

时间:2013-06-03 22:12:32

标签: android xml string http client

我正在为大学开发一个软件项目,我们必须在Android上将客户端实现为特定的REST服务。 REST-Post接受两个参数:

  • document(一个XML文档,在我的代码中,作为从“TriageTag” - 对象创建的org.w3c.dom.Document存在)
  • timestamp(一个字符串,表示客户端的POST时间)

到目前为止我所拥有的:

            [... timestamp / post url preparations etc. ...]

            //Generate String from XML
            InputSource is = new InputSource(c.getResources().openRawResource(R.raw.cda_template));
            Document doc = CDAParser.TriageTagObjectToXml(tag, is);

            //Data
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>

            //FILL IN: SET DOC AS PARAM. WHO DO I DO THIS!?!?

            nameValuePairs.add(new BasicNameValuePair("timestamp", timestamp));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            // Execute HTTP Post Request
            HttpResponse response = client.execute(httppost);
            StatusLine status = response.getStatusLine();

            [... check status etc. ... ]

0 个答案:

没有答案