views:

43

answers:

0

I am using the following code to try to send a POST to a web service

StringBuffer helloReq = new StringBuffer();    
    helloReq.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
    helloReq.append("<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"  xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"&gt;");
   helloReq.append("<soap12:Body>");
   helloReq.append("<HelloWorldResponse xmlns=\"http://tempuri.org/\"&gt;");
   helloReq.append("<HelloWorldResult>string</HelloWorldResult>");
   helloReq.append("</HelloWorldResponse>");
   helloReq.append("</soap12:Body>");
   helloReq.append("</soap12:Envelope>");



   HttpClient httpclient = new DefaultHttpClient();
   HttpPost httppost = new HttpPost(mURL);

   String SOAPReqHello = helloReq.toString();

   StringEntity se = new StringEntity(SOAPReqHello,HTTP.UTF_8);
  se.setContentType("text/xml");
  httppost.addHeader("Content-Type","application/soap+xml; charset=UTF-8");
  String soapLength = (""+SOAPReqHello.length());
  httppost.addHeader("Content-Length", soapLength ); 
  httppost.setEntity(se);
  ResponseHandler<String> responseHandler = new BasicResponseHandler();
  String httpResponse=httpclient.execute(httppost, responseHandler);

I get a Client Protocol Exception with a null message.

Since the service supports an HTTP GET Request to the same URL appended with HELLOWORLD?, I tried that and the the response string is the correct XML with Hello World.

Any ideas on why the HTTPPOST is not getting the exception?

Thanks