I have recently started doing Android programming. I have come across a problem. Currently I have built a XML string request called 'sendData'. This sendData needs to be sent to the server to validate if the user account is valid or not.
Currently when I try to send the request, I make contact with the server, but I get a default generic response error back which makes me believe that the XML isn't being sent correcrtly.
public void postData(String sendData) {
// Create a new HttpClient and Post Header
System.out.println("SENDDATA" + sendData);
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www......");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(0);
nameValuePairs.add(new BasicNameValuePair(sendData, sendData));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
inputStreamToString(response.getEntity().getContent());
}
catch (ClientProtocolException e)
{
// TODO Auto-generated catch block
}
catch (IOException e)
{
// TODO Auto-generated catch block
}
}
The above is the code I am using to send the data. I believe the problem is happening within the 'try' section, possibly. I have searched for similar problems on this forum and cannot find the answer I was looking for.
Any help will be appreciated.
Thanks,
EDIT:
In the log cat. When I print the string off, it looks like this.
07-19 15:35:36.642: INFO/System.out(2204): <Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="1.0" xsi:noNamespaceSchemaLocation="http://www.example.com">
07-19 15:35:36.642: INFO/System.out(2204): <Identification>
07-19 15:35:36.642: INFO/System.out(2204): <UserID>[email protected]</UserID>
07-19 15:35:36.642: INFO/System.out(2204): <Password>password</Password>
07-19 15:35:36.642: INFO/System.out(2204): </Identification>
07-19 15:35:36.642: INFO/System.out(2204): <Service>
07-19 15:35:36.652: INFO/System.out(2204): <ServiceName>AccountVerify</ServiceName>
07-19 15:35:36.652: INFO/System.out(2204): <ServiceDetail/>
07-19 15:35:36.652: INFO/System.out(2204): </Service>
07-19 15:35:36.652: INFO/System.out(2204):
Each element has it's own line in the LogCat. Could this be the problem?