0

我正在尝试通过 SOAP 和 WSDL ( http://wiki.affiliatewindow.com/index.php/Affiliate_service_APIV3 )连接(通过 google 电子表格中的脚本编辑器)到 API 。

我正在努力创建标头 XML 对象,根据示例(来自上面的链接)应该有两个元素,“UserAuthentication”和“getQuota”。如果我仅发送带有用户身份验证的标头,则会收到服务器错误响应;如果我尝试发送这两个元素,我会收到身份验证错误。

任何帮助都感激不尽!

** 更新 ** 身份验证标头似乎正在工作(或者至少没有返回任何错误);我现在得到的错误是“程序'getTransactionList'不存在”(它应该存在)。

到目前为止,这是我的代码:

function testSOAP() {
// Affiliate Window API from here
  var wsdl = SoapService.wsdl("http://api.affiliatewindow.com/v3/AffiliateService?wsdl");

  var apiService = wsdl.getService( wsdl.getServiceNames() );
  //Logger.log(apiService); // ApiService

  var headerA = [
    "ns1:UserAuthentication",
    { "SOAP-ENV:mustUnderstand" : "true" },
    { "SOAP-ENV:actor" : "http://api.affiliatewindow.com" },
    [ "ns1:iId", "******" ],
    [ "ns1:sPassword", "**************************************" ],
    [ "ns1:sType", "affiliate" ]
  ];
  var headerQ = [
    "ns1:getQuota", "true"
  ];

  var paramJ = [
    "ns1:getTransactionList",
    [ "ns1:dStartDate", "2011-08-01T00:00:00" ],
    [ "ns1:dEndDate", "2011-08-30T23:59:59" ],
    [ "ns1:sDateType", "transaction" ]
  ];
  // I read that the paramaters should be sent as an XML element, not JSON (as above)
  // but neither of the formats seem to work
  var paramX = Xml.element("ns1:getTransactionList", [
                           Xml.element("ns1:dStartDate", ["2011-08-01T00:00:00"]),
                           Xml.element("ns1:dEndDate", ["2011-08-30T23:59:59"]),
                           Xml.element("ns1:sDateType", ["transaction"])
  ]);

  // this returns the generated xml that will be sent
  var result = apiService.getSoapEnvelope("getTransactionList", paramX, [headerA, headerQ]);
  Logger.log(result);

  var transL = apiService.getOperation("getTransactionList");
  //Logger.log(transL);

  var env = transL.invokeOperation([paramJ], [headerA, headerQ]);
  Logger.log(env);

  Logger.getLog();
}
4

1 回答 1

0

我从未使用过 Apps Script Soap 服务,但您是否尝试过为标题使用一维数组?(因为您使用的是二维的)。例如

var header = [headerA, headerQ]; //your snippet had "extra" brackets

var result = apiService.invokeOperation("getTransactionList", [param], header);
Logger.log(result);
于 2012-05-08T17:51:12.367 回答