2012-06-15 97 views
1

我是新來android.I有一個xml足見其細節將通過SOAP服務器上發送,所以請告訴我怎麼以下XML轉換在KSOAP request.Thanks如何將xml轉換爲KSOAP請求?

<location> 
<locationId>132</locationId> 
<name>test</name> 
<qualifiedCoordinates> 
<altitude>10</altitude> 
</qualifiedCoordinates> 
</location> 

回答

0
SoapObject request = new SoapObject(NAMESPACE, METHOD); 
    request.addProperty("locationId", 132); 
    request.addProperty("name", test); 
    request.addProperty("altitude", 10); 
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
      SoapEnvelope.VER11); 
    envelope.dotNet = true; 
    envelope.setOutputSoapObject(request); 

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 

    try { 
     androidHttpTransport.call(SOAP_ACTION, envelope); 
     SoapObject result = (SoapObject) envelope.getResponse();} 
catch(Exception e) { 
     tempText.setText("Error"); 
     e.printStackTrace(); 
    } 
+0

謝謝,但有一個疑問,'高度'是在'合格的質量協調'中定義的,所以直接添加爲要求的財產是正確的。 – user1368422

+0

我不是100%確定,但最有可能的是。知道它的唯一方法就是嘗試一下,看看它是否會給出任何錯誤。 – Swayam

+0

是它給錯誤,sayin解組錯誤 – user1368422