首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用google-apps脚本的Soap服务调用操作失败,错误代码为500

使用google-apps脚本的Soap服务调用操作失败,错误代码为500
EN

Stack Overflow用户
提问于 2012-09-10 00:47:40
回答 1查看 925关注 0票数 2

我正在尝试使用Google App脚本调用由WebserviceX提供的GetWeather soap服务,并在运行该脚本时收到以下错误:

代码语言:javascript
复制
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. ---&gt; 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请求中的哪个元素导致了问题。下面是相同的脚本代码:

代码语言:javascript
复制
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

EN

回答 1

Stack Overflow用户

发布于 2012-09-10 02:34:11

在您的代码片段中,似乎添加了多个逗号中的一个。试着去掉最后一个"India"],];,最后一个在数组中定义了一个空索引。

我已经看过webservicex网站了。实际上,有一种更容易获得数据的方法。该站点还提供HTTP GET服务

代码语言:javascript
复制
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服务呢?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12340938

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档