2014-01-12 28 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」。