String namespace ="http://tempuri.org/";
String endpoint = "http://116.55.248.28:9999/UserInfoService.asmx";
String method = "CheckUserLoginIsExit";
String SOAPAction = "http://tempuri.org/CheckUserLoginIsExit";
SoapObject request = new SoapObject(namespace, method);
request.addProperty("UserLogin", "muou");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.encodingStyle="UTF-8";
envelope.bodyOut=request;
envelope.dotNet=true;


//envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(endpoint);
try {
androidHttpTransport.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 = null;
SoapObject object = (SoapObject )envelope.bodyIn;
if(object==null){
Toast.makeText(getApplicationContext(), "object is null", Toast.LENGTH_LONG).show();
}
为什么object输出的结果是null???不知道问题的所在

解决方案 »

  1.   

    我调用了一下你的webService,没有问题呀。下面是我的全部代码,你参考一下。
    可以的话就结贴吧public class TestWebService extends Activity {
        
    private static String NameSpace="http://tempuri.org/";//这个不要改
    //http://116.55.248.28:9999/UserInfoService.asmx
    private static String u="http://116.55.248.28:9999";//请更换成你要访问的服务器地址
    private static String webService="/UserInfoService.asmx";//webService目录
    private static String MethodName="CheckUserLoginIsExit";//要调用的webService方法
    private static String soapAction=NameSpace+MethodName;
    private static String url=u+webService;//最终要访问的网址

    private TextView tv;

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        
            tv=(TextView)findViewById(R.id.tv);
            tv.setText(ws());
        }
        //webService操作要访问网络,所以最好是使用线程来做,这里只是示例,所以就不考虑了
        private String ws(){
         String result="";
         try{
         SoapObject request=new SoapObject(NameSpace,MethodName);//NameSpace
         //webService方法中的参数,这个根据你的webservice来,可以没有。
         //请注意,参数名称和参数类型,客户端和服务端一定要一致,否则将可能获取不到你想要的值
         request.addProperty("UserLogin", "muou");
         //request.addProperty("y", 6);
        
         SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(
         SoapEnvelope.VER11);
        
         envelope.dotNet=true;//访问.NET的webservice
        
         envelope.setOutputSoapObject(request);
        
         HttpTransportSE ht=new HttpTransportSE(url);
        
         ht.call(soapAction, envelope);//调用call方法,访问webservice
        
         if(envelope.getResponse()!=null){
         SoapPrimitive response=(SoapPrimitive)envelope.getResponse();
         //如果要返回对象集合,在服务端可以将对象或集合序列化成json字符串返回,这边再反序列化成对象或集合
         result=response.toString();//这里获得了webService的返回值
         }
        
         }catch(Exception e){
         result=e.getMessage();
         System.out.println("e="+result);
         }
         return result;
        }
    }
      

  2.   

    可以的话 加个qq吧 还有一些问题要问,我用response就报错这是怎么回事 所以我只能用bodyin
      

  3.   

    你也没再我的代码进行改动啊  为什么你可以我却不行????只是我是用bodyin 你是用response 这应该没有什么影响吧啊??