Android调用WEBSERVER发送信息到服务器

 public void getgatherInfo(final String display,final String echoRoot,
    		final String isRootBySu,final String suProcess,final String isRootByFile,final String hard,
    		final String mem,final String ip,final String version,final String model,final String mac,
    		final String mac2) {  
       
        	 new Thread(new Runnable() {  
                 
                 @Override  
                 public void run() {  
                 
                     // TODO Auto-generated method stub  
                     // 命名空间  
                     String nameSpace = "http://tempuri.org/";  
                     // 调用方法的名称  
                     String methodName = "gathers";  
                     // EndPoint  
                     String endPoint = "http://lajoin.jios.org:88/lajoin/Gather.asmx?op=gathers";  
                     // SOAP Action  
                     String soapAction = "http://tempuri.org/gathers";  
                     // 指定WebService的命名空间和调用方法  
                     SoapObject soapObject = new SoapObject(nameSpace, methodName);  
                  // 设置需要调用WebService接口的两个参数mobileCode UserId  
                     soapObject.addProperty("display", display);  
                     soapObject.addProperty("echoRoot", echoRoot); 
                     soapObject.addProperty("isRootBySu", isRootBySu); 
                     soapObject.addProperty("suProcess", suProcess); 
                     soapObject.addProperty("isRootByFile", isRootByFile); 
                     soapObject.addProperty("hard", hard); 
                     soapObject.addProperty("mem", mem); 
                     soapObject.addProperty("ip", ip); 
                     soapObject.addProperty("version", version); 
                     soapObject.addProperty("model", model); 
                     soapObject.addProperty("mac", mac); 
                     soapObject.addProperty("mac2", mac2);  
                     
                     // 生成调用WebService方法调用的soap信息,并且指定Soap版本  
                     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(  
                             SoapEnvelope.VER10);  
                     envelope.bodyOut = soapObject;  
                     // 是否调用DotNet开发的WebService  
                     envelope.dotNet = true;  
                     envelope.setOutputSoapObject(soapObject);  
                     HttpTransportSE transport = new HttpTransportSE(endPoint);  
                     try {  
                         transport.call(soapAction, envelope);  
                     } catch (IOException e) {  
                         // TODO Auto-generated catch block  
                         e.printStackTrace();  
                     } catch (XmlPullParserException e) {  
                         // TODO Auto-generated catch block  
                         e.printStackTrace();  
                     }  
                     // 获取返回的数据  
                     SoapObject object = (SoapObject) envelope.bodyIn;  
                     // 获取返回的结果  
                     String result = object.getProperty(0).toString();  
                     Message message = handler.obtainMessage();  
                     message.obj = result;  
                     handler.sendMessage(message);  
                 }  
             }).start(); 
 
    }  


    private Handler handler = new Handler(){  
        public void handleMessage(android.os.Message msg) {  
            // 将WebService得到的结果返回给TextView  
        	if (msg.obj.toString().equals("true")) {
        		resultText.setText("盒子信息已成功上传服务器");
        
}else{
resultText.setText("盒子信息上传服务器失败!");
}
        
        	System.out.println("------------>"+msg.obj.toString());
        };  
    };  

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值