I haven't used the Java HttpClient before and the documentation is
confusing. Say I want to send a POST to the URL "https://domain/foo/
bar". I'm accessing a server with an XML API that defines the message
to send like this:

POST https://domain/foo/bar
Content-Type: application/xml
Content-Length:
SERVER-ACTION:API_AddField
<serverapi>
   <label>label</label>
   <type>type</type>
   <mode>mode</mode>
   <ticket>ticket</ticket>
</serverapi>

And the response to expect like this:

<?xml version="1.0" ?>
<serverapi>
   <action>API_AddField</action>
   <errcode>0</errcode>
   <errtext>No error</errtext>
</serverapi>

Now, I can build and parse the portion inside the serverapi tags but
I'm not sure how the HttpClient handles the header. If I use the
standard code like this:

                DefaultHttpClient myHttpClient = new
DefaultHttpClient();
                HttpPost httppost = new HttpPost(https://domain/foo/bar);
                StringEntity entity = new StringEntity( /* not sure */ );
                httppost.setEntity(entity);
                HttpResponse response = myHttpClient.execute(httppost);

In the area shown as "not sure", should I pre-pend the entire header
in front of the xml section, just as it's shown in the server API
document or does the client take care of the first line, since it
knows the URL?

Is there a way to see exactly what is about to be sent right before I
call HttpClient.execute?

As for parsing the response, I believe I can just do this:

                        XmlPullParser parser = Xml.newPullParser();
                        parser.setInput(response.getEntity().getContent(), 
null);

Or do I need to strip anything off the response content before I start
parsing the xml? I took a few stabs at this and it looks like there's
some HTTP bookkeeping information at the start of the response
content.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to