2016-12-29 74 views
1

我使用SOAP訪問如下所示的代碼Web服務,並得到了下面的錯誤,這是我需要理解幫助:的Android KSOAP錯誤

的SOAPFault - Fault代碼:「SOAP:服務器」 faultstring:'System.Web.Services.Protocols.SoapException:服務器無法 處理請求。 ---> System.Data.SqlClient.SqlException:過程或 函數'getWCity'需要提供的參數'@CountryName'不是 。 在WebServicex.GlobalWeather.GetCitiesByCountry(字符串國家或地區名稱) ---內部異常堆棧跟蹤結束---」 faultactor: '空' 的細節:[email protected]

public String Test() 
{ 
    String SOAP_ACTION = "http://www.webserviceX.NET/GetCitiesByCountry"; 
    String METHOD_NAME = "GetCitiesByCountry"; 
    String NAMESPACE = "http://www.webserviceX.NET/"; 
    String URL = "http://www.webservicex.com/globalweather.asmx?WSDL"; 

    SOAP_ACTION = NAMESPACE + METHOD_NAME; 
    String result="invalid"; 
    try 
    { 
     SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME); 
     Request.addProperty("CountryName", "India"); 

     SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
     soapEnvelope.dotNet = true; 
     soapEnvelope.setOutputSoapObject(Request); 
     HttpTransportSE transport = new HttpTransportSE(URL); 
     transport.call(SOAP_ACTION, soapEnvelope); 
     SoapPrimitive resultString; 
     resultString = (SoapPrimitive) soapEnvelope.getResponse(); 
     result = resultString .toString() ; 
     return result ; 
    } 
    catch (Exception e) 
    { 
     e.printStackTrace(); 
    } 
    return result; 
} 
+0

句法改進 – clearlight

回答

2

SoapObject(NAMESPACE,METHOD_NAME);它使用的命名空間:

http://www.webserviceX.NET/

,但它應該是

http://www.webserviceX.NET

你可以改變爲:

String METHOD_NAME = "GetCitiesByCountry"; 
String NAMESPACE = "http://www.webserviceX.NET"; 


SOAP_ACTION = NAMESPACE + "/" + METHOD_NAME; 
+1

解決了問題謝謝。 –