gpt4 book ai didi

java - Android KSoap 错误

转载 作者:行者123 更新时间:2023-11-29 19:26:03 25 4
gpt4 key购买 nike

我在下面显示的代码中使用 soap 访问 Web 服务并收到以下错误,我需要帮助来理解:

SoapFault - faultcode: 'soap:Server' faultstring: 'System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Procedure or function 'getWCity' expects parameter '@CountryName', which was not supplied. at WebServicex.GlobalWeather.GetCitiesByCountry(String CountryName) --- End of inner exception stack trace ---' faultactor: 'null' detail: 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;
}

最佳答案

SoapObject( namespace ,方法名称);它用作命名空间:

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

但应该是

"http://www.webserviceX.NET"

你可以改成:

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


SOAP_ACTION = NAMESPACE + "/" + METHOD_NAME;

关于java - Android KSoap 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41379825/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com