我正在尝试使用Google App脚本调用由WebserviceX提供的GetWeather soap服务,并在运行该脚本时收到以下错误:
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请求中预期的参数,但我无法获得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
发布于 2012-09-10 02:34:11
在您的代码片段中,似乎添加了多个逗号中的一个。试着去掉最后一个"India"],];,最后一个在数组中定义了一个空索引。
我已经看过webservicex网站了。实际上,有一种更容易获得数据的方法。该站点还提供HTTP GET服务
HTTP GET
The following is a sample HTTP GET request and response. The placeholders shown need to be replaced with actual values.
GET /globalweather.asmx/GetWeather?CityName=string&CountryName=string HTTP/1.1
Host: www.webservicex.net
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://www.webserviceX.NET">string</string>为什么不使用UrlFetch服务呢?
https://stackoverflow.com/questions/12340938
复制相似问题