简体   繁体   English

Android KSoap 错误

[英]Android KSoap error

I'm using soap to access a web service in the code shown below and get the following error, which I need help in understanding:我正在使用soap访问下面显示的代码中的Web服务并收到以下错误,我需要帮助理解:

SoapFault - faultcode: 'soap:Server' faultstring: 'System.Web.Services.Protocols.SoapException: Server was unable to process request. SoapFault - 故障代码:'soap:Server' 故障字符串:'System.Web.Services.Protocols.SoapException:服务器无法处理请求。 ---> System.Data.SqlClient.SqlException: Procedure or function 'getWCity' expects parameter '@CountryName', which was not supplied. ---> System.Data.SqlClient.SqlException:过程或函数“getWCity”需要未提供的参数“@CountryName”。 at WebServicex.GlobalWeather.GetCitiesByCountry(String CountryName) --- End of inner exception stack trace ---' faultactor: 'null' detail: org.kxml2.kdom.Node@bf51d7c在 WebServicex.GlobalWeather.GetCitiesByCountry(String CountryName) --- 内部异常堆栈跟踪结束 ---' faultactor: 'null' 详细信息:org.kxml2.kdom.Node@bf51d7c

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;
}

The SoapObject(NAMESPACE, METHOD_NAME); SoapObject(NAMESPACE, METHOD_NAME); it uses as the namespace:它用作命名空间:

" http://www.webserviceX.NET/ " " http://www.webserviceX.NET/ "

but it should be但应该是

" http://www.webserviceX.NET " http://www.webserviceX.NET

you could change to:你可以改为:

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


SOAP_ACTION = NAMESPACE + "/" + METHOD_NAME;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM