我正在尝试使用 Google App 脚本调用 WebserviceX 提供的 GetWeather 肥皂服务,并在运行脚本时收到以下错误:
Request failed for http://www.webservicex.net/globalweather.asmx returned code 500. Server response: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Procedure or function 'getWeather' expects parameter '@CountryName', which was not supplied. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at WebServicex.GlobalWeather.GetWeather(String CityName, String CountryName) --- End of inner exception stack trace ---</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope> (line 12)
我已经检查了 GetWeather SOAP 服务的 SOAP 请求中预期的参数,但我无法了解导致问题的肥皂请求中的哪个元素。以下是相同的脚本代码:
function testSoapSerivce() {
var wsdl2 = SoapService.wsdl("http://www.webservicex.net/globalweather.asmx?WSDL");
Logger.log(wsdl2.getServiceNames());
var weatherService=wsdl2.getService("GlobalWeather");
var param2 = [ "GetWeather",
{ "xmlns" : "http://www.webservicex.net/" },
[ "CityName", "New Delhi" ],
[ "CountryName", "India"],
];
var envelope2 = weatherService.getSoapEnvelope("GetWeather", param2)
Logger.log(envelope2);
var result2 = weatherService.GetWeather(param2);
Logger.log(result2.toXmlString());
}
GetWeather 服务详情可在以下链接中找到:
http://www.webservicex.net/ws/WSDetails.aspx?CATID=12&WSID=56