2014-01-12 25 views
0
private final String zipCodenameSpace ="http://www.webserviceX.NET/"; 
private final String zipURL="http://www.webserviceX.net/uszip.asmx"; 
private final String zipSoapAction ="http://www.webserviceX.NET/GetInfoByCity"; 
private final String zipMethodName="GetInfoByCity"; 



SoapObject request = new SoapObject(zipCodenameSpace, zipMethodName); 
     PropertyInfo cityInfo = new PropertyInfo(); 
     cityInfo.setName("USCity"); 
     cityInfo.setValue(city); 
     // cityInfo.setType(String.class); 
     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
     request.addProperty(cityInfo); 
     TextView tv = (TextView) findViewById(R.id.tv1); 

     envelope.dotNet = true; 

     envelope.setOutputSoapObject(request); 
     HttpTransportSE androidHttpTransport = new HttpTransportSE(zipURL); 

     try { 
      androidHttpTransport.call(zipSoapAction, envelope); 

     // Object response =(SoapObject) envelope.getResponse(); 
      SoapObject response = (SoapObject) envelope.getResponse(); 

      Log.d("This is an element", response.toString()); 
      // tv.setText(response.toString()); 

      // return response.toString(); 

      } catch (Exception e) { 
      e.printStackTrace(); 
         } 

显示null异常。在soapObject响应中发生错误。安卓肥皂web服务 - 不检索输出

我试图使用肥皂基元,但不工作。请帮我问题出在哪里

鉴于Webservice返回xml。

回答

0
cityInfo.setValue(city); 

你在哪里在你的代码中获取这个“城市”值?我认为那是问题。为了测试,你可以直接在这里设置它为字符串,比如“NewYork”。