开发者

problem in sending a SOAP request

I am using the follwing code to send SOAP request.

 String str = new StringBuilder("POST /WrenchTelLink/WrenchENTService.asmx HTTP/1.1\n")
              .append("Host: 59.160.183.14\n")
              .append("Content-Type: text/xml; charset=utf-8\n")
              .append("Content-Length: LLLLLL\n")
              .append("SOAPAction: \"http://WrenchGlobal/GetToDoList\"\n ")
              .append("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
              .append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-      
               instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" 
               xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n")
              .append("<soap:Body>\n")
              .append("<GetToDoList xmlns=\"http://WrenchGlobal/\">\n")
              .append("<viPeriod>IIIIII</viPeriod>\n")
              .append("<vsUserID>SSSSSS</vsUserID>\n")
              .append("</GetToDoList>\n")
              .append("</soap:Body>\n")
              .append("</soap:Envelope>\n").toString();
 String temp = str.replaceAll("LLLLLL",Integer.toString(str.length()))
   .replaceAll("SSSSSS",ph).replaceAll("IIIIII",Integer.toString(period));
  HttpClient httpclient = new DefaultHttpClient();
  HttpPost httppost = new HttpPost(url);

  try
   {
      StringEntity se = new StringEntity(temp,HTTP.UTF_8);

      se.setContentType("text/xml");  
      httppost.setHeader("Content-Type","application/soap+xml;charset=UTF-8");

      httppost.setEntity(se);  
      BasicHttpResponse httpResponse = (BasicHttpResponse)httpclient.execute(httppost);

      if(httpResponse.getStatusLine().toString()!="") 
         Toast.makeText(TelLinkActivity.this, httpResponse.getStatusLine().toString()
                    , Toast.LENGTH_SHORT).show();
      else
          Toast.makeText(TelLinkActivity.this,"Failed", Toast.LENGTH_SHORT).show();

开发者_开发问答     }
    catch(ClientProtocolException e)
    {
      e.printStackTrace();
    }
    catch(IOException e)
    {
      e.printStackTrace();  
    }    

Its not showing any of the TOAST messages. I am not getting what i am supposed understand from this. Its not working at all. Could anyone tell me if there is something wrong with the code..?


show Toast in ui thread, by runOnUiThread for example

runOnUiThread(new Runnable() {
    public void run() {
      Toast.makeText(TelLinkActivity.this,"Failed", Toast.LENGTH_SHORT).show();
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜