开发者

Soap API error - incorrect type?

I am currently trying to consume an API that is working fine in my browser - my code is as follows:

function getHistory() {

  var wsdl = SoapService.wsdl("http://zulutrade.com/WebServices/Performance.asmx?WSDL");

  var performanceService = wsdl.getService("PerformanceWebService");

  var param = Xml.element("GetProviderTrades", [
                Xml.attribute("xmlns", "ZuluTrade.WebServices"),
                Xml.element("length",["100"]),
                Xml.element("sortBy",["dc"]),
                Xml.element("sortAscending",[false]),
                Xml.element("providerId",["24508"]),
                Xml.element("currencyIds",["[]"]),
                Xml.element("fromDateStr",["1984-04-24"]),
                Xml.element("toDateStr",["2011-09-10"]),
                Xml.element("validTrades",[true]),
                Xml.element("lotSize",["2"])
              ]);

  //var envelope = performanceService.getSoapEnvelope("GetProviderTrades", param)
  //Logger.log(envelope);

  var result = performanceService.GetProviderTrades(param);

  Logger.log(result);
}

This appears to be connecting to the service, but is generating the error:

Request failed for http://zulutrade.com/WebServices/Performance.asmx returned code 500. Server response: soap:ClientServer was unable to read request. ---> There is an error in XML document (1, 640). ---> Instance vali开发者_JAVA技巧dation error: '2' is not a valid value for LotSize. (line 26)

In order to set each of the parameters, I have copied exactly the payload from the developer tools of Chrome when accessing the page (go to http://www.zulutrade.com/TradeHistoryIndividual.aspx?pid=24508 and change the number of visible trades while viewing the XHR requests to see the payload). As I have set the lotSize to 2, as per the payload in the browser request, I would have expected this to work, but it clearly does not.

Looking at the schema at http://zulutrade.com/WebServices/Performance.asmx?WSDL, I can see the following for lotSize:

<s:element minOccurs="1" maxOccurs="1" name="lotSize" type="tns:LotSize"/>

This looks like it has type tns:LotSize - is this why I am getting the error? If so, how can I pass something of this type in my request?

Thanks!


afaik from WSDL you can see that

<s:simpleType name="LotSize">
    <s:restriction base="s:string">
        <s:enumeration value="Micro"/>
        <s:enumeration value="Mini"/>
        <s:enumeration value="Standard"/>
    </s:restriction>
</s:simpleType>

So lotSize can be

Xml.element("lotSize","Mini") // 2nd value, instead of ["2"]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜