2014-07-03 56 views
1

我正在使用kso​​ap2與遠程Web服務進行通信。出於某種原因,我添加到soapObject的屬性不會被髮送。我哪裏錯了?我嘗試了一切,當我執行請求xml的直接發佈時,我得到了一個響應,但這不是我想要的。我也得到了服務器的響應,但是我發佈的任何值都沒有被傳遞。我已經閱讀過每個博客,官方文檔甚至相關的SO問題,我錯過了什麼?Android ksoap2,數據未被髮布

這是從異步任務的doInBackground()調用的方法的一個片段。

public SoapObject getSoapObject() { 
     // Create request 
     SoapObject requesty = new SoapObject(NAMESPACE, METHOD_NAME); 

     // Add the property to request object 
     requesty.addProperty(getPropertyInfo("PARAMETER_1", "VALUE_1")); 

     // Create envelope 
     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
     envelope.dotNet = true; 

     // Set output SOAP object 
     envelope.setOutputSoapObject(requesty); 

     // Create HTTP call object 
     HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
     SoapObject soapObject = null; 
     try { 
      // Send to web service 
      androidHttpTransport.call(SOAP_ACTION, envelope);  
      soapObject = (SoapObject) envelope.getResponse(); 
     } catch (SoapFault e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } catch (HttpResponseException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } catch (XmlPullParserException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
     return soapObject; 
    } 

    private PropertyInfo getPropertyInfo(String name, String value) { 
     PropertyInfo propInfo = new PropertyInfo(); 
     propInfo.setName(name); 
     propInfo.setValue(value); 
     propInfo.setType(string.class); 
     return propInfo; 
    } 

回答

0

代替使用kso​​ap2的,我通過HttpPost直接發佈,手動自定義XML解析器解析的不同的值。我知道這可能不是最好的選擇,但現在SOAP只是老派。