如何理解node-soap“描述”功能?

时间:2014-08-13 23:41:12

标签: node.js soap

我正在尝试使用节点SOAP npm模块(https://github.com/vpulim/node-soap)服务。

var soap = require('soap');
var soapWSDL = "https://webservice.s7.exacttarget.com/etframework.wsdl";

soap.createClient(soapWSDL, function (err, client) {
    if (err) {
      return callback(err, null);
    }

    client.setSecurity(new soap.WSSecurity(self.username, self.password));

    console.log("describe", client.describe());
    console.log("retrieve", client.describe().PartnerAPI.Soap.Retrieve);
});

第一个日志显示了可用的方法......

但是我试图从第二个控制台了解params所需的确切格式.log ...

更具体地说,当我致电client.Retrieve(options,function(e,r){}); options所需的格式是什么时?

以下是两个console.logs的输出

说明:

 { PartnerAPI: 
   { Soap: 
      { Create: [Object],
        Retrieve: [Object],
        Update: [Object],
        Delete: [Object],
        Query: [Object],
        Describe: [Object],
        Execute: [Object],
        Perform: [Object],
        Configure: [Object],
        Schedule: [Object],
        VersionInfo: [Object],
        Extract: [Object],
        GetSystemStatus: [Object] } } }

提取:

 { input: 
   { RetrieveRequest: 
      { 'ClientIDs[]': [Object],
        ObjectType: 'xsd:string',
        'Properties[]': 'xsd:string',
        Filter: [Object],
        'RespondTo[]': [Object],
        'PartnerProperties[]': [Object],
        ContinueRequest: 'xsd:string',
        QueryAllAccounts: 'xsd:boolean',
        RetrieveAllSinceLastBatch: 'xsd:boolean',
        RepeatLastResult: 'xsd:boolean',
        Retrieves: [Object],
        Options: [Object],
        targetNSAlias: 'tns',
        targetNamespace: 'http://exacttarget.com/wsdl/partnerAPI' } },
  output: 
   { OverallStatus: 'xsd:string',
     RequestID: 'xsd:string',
     'Results[]': 
      { Client: [Object],
        PartnerKey: 'xsd:string',
        'PartnerProperties[]': [Object],
        CreatedDate: 'xsd:dateTime',
        ModifiedDate: 'xsd:dateTime',
        ID: 'xsd:int',
        ObjectID: 'xsd:string',
        CustomerKey: 'xsd:string',
        Owner: [Object],
        CorrelationID: 'xsd:string',
        ObjectState: 'xsd:string',
        targetNSAlias: 'tns',
        targetNamespace: 'http://exacttarget.com/wsdl/partnerAPI' } } }

2 个答案:

答案 0 :(得分:1)

在此示例中,您应该查看密钥名称和格式。例如,任何末尾带有[]的键意味着这应该是SOAP Sequence。如果没有看到输入/输出的整个格式,我就无法100%肯定 - 您可以尝试使用Node.js'util函数来深入检查对象。 例如:

var utils = require('utils');
/* later */
console.log( utils.inspect( testObject, {depth: null} ) );

尽可能多地回答你的问题:

var args = {
  ClientIDs: [{ /* Some object - not sure without inspect */ }],
  ObjectType: 'someString',
  Properties: ['someString', 'someString'],
  Filter: { /* Some object - not sure without inspect */ },
  RespondTo: [{ /* Some object - not sure without inspect */ }],
  PartnerProperties: [{ /* Some object - not sure without inspect */ }],
  ContinueRequest: 'someString',
  QueryAllAccounts: true, /* or false */
  RetrieveAllSinceLastBatch: true, /* or false */
  RepeatLastResult: true, /* or false */
  Retrieves: [{ /* Some object - not sure without inspect */ }],
  Options: [{ /* Some object - not sure without inspect */ }]
}

client.RetrieveRequest(args, function(err, result, raw, soapHeader) {
  /* do something with the result */
});

答案 1 :(得分:0)

您可以使用JSON.stringify选项查看从client.describe()获得的输出的详细信息。它将以.json格式显示所有参数。

相关问题