简体   繁体   中英

How to understand node-soap “describe” function?

I'm attempting to use the node SOAP npm module( https://github.com/vpulim/node-soap ) service.

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);
});

The first log shows the available methods...

But i'm trying to understand the exact format required for params from the second console.log...

More specifically, when i call client.Retrieve(options,function(e,r){}); what is the required format of options supposed to be?

Here is the output from the two console.logs

Describe:

 { 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] } } }

Retrieve:

 { 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' } } }

In this example you should be looking at the key names and formats. For example any key with a [] at the end means this should be a SOAP Sequence . Without seeing the entire format of the input / output I can't be 100% certain on some - you could try using Node.js' util function to get a deep inspect of the object. For example:

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

To answer your question as much as I can:

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 */
});

You can use JSON.stringify options to look at the details of the output you are getting from client.describe() . It will show you all the parameters in .json format.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM