6

I am trying to consume ExactTarget Web Service API from node.js using node-soap. With other webservices, I instantiate a client with the WSDL

var soap = require('soap');
var url = "http://www.webservicex.net/stockquote.asmx?WSDL";
var args = {"symbol" : "DOX"};
soap.createClient(url,function(err,client){
    if (err) throw err;
    console.log(client.describe());
})

The above code-fragment prints out something like this

{ StockQuote:     
    { StockQuoteSoap: { GetQuote: [Object] },
      StockQuoteSoap12: { GetQuote: [Object] } 
    } 
}

Looking at the output, I can invoke a WebService Method like

   client.StockQuote.StockQuoteSoap.GetQuote(args,function(err,result)

When I try to instantiate a client with the ExactTarget URL https://webservice.exacttarget.com/etframework.wsdl, the client.describe call fails with the message

RangeError: Maximum call stack size exceeded

The node-soap documentation shows the following way to invoke a WebService method

Client.service.port.method(args, callback) - call a method using a specific service and port

How do I invoke a WebService method such as Create? Specifically, what do I specify for service & port

3 Answers 3

4

We haven't had much luck implementing this library with exacttarget's SOAP webservices. We suggest using ws.js.

Using this library, you can build out your SOAP packets directly. Here is some sample code to describe the subscriber object.

var ws = require('ws.js');
var Http = ws.Http;
var Security = ws.Security;
var UsernameToken = ws.UsernameToken;

  var request = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +   
                      '<soapenv:Header>' +
                           '<ns1:fueloauth xmlns:ns1="http://exacttarget.com">[USE YOUR OAUTH TOKEN]</ns1:fueloauth>' +
                      '</soapenv:Header>' +
                      '<soapenv:Body>' +
                      '<DefinitionRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">' +
                         '<DescribeRequests>' +
                            '<ObjectDefinitionRequest>' +
                               '<ObjectType>Subscriber</ObjectType>' +
                            '</ObjectDefinitionRequest>' +
                         '</DescribeRequests>' +
                      '</DefinitionRequestMsg>' +
                   '</soapenv:Body>' +
                '</soapenv:Envelope>'


var ctx =  { request: request 
           , url: "https://webservice.s6.exacttarget.com/Service.asmx"
           , action: "Describe"
           , contentType: "text/xml" 
           }


var handlers =  [ new Http() ]

ws.send(handlers, ctx, function(ctx) {                    
  console.log("response: " + ctx.response);
})
1

We're not having any issues using SOAP and Node.js. We use node-soap for this purpose and it's working well for us.

If you're having issues, you should just test sending a soap request envelope locally using cURL. This is an easy way to confirm your requests are structured correctly. Save your SOAP request as an XML file named 'request.xml' and then call it from the command line using cURL:

 curl -XPOST -H "Content-type: text/xml; charset=utf-8" -H "SOAPAction: XXXXXX" -d @request.xml https://webservice.test.exacttarget.com/Service.asmx

Where SOAPAction uses the appropriate verb for the request; Create, Retrieve, Extract, etc. For example: "SOAPAction: Retrieve".

1

The node-soap module has been updated recently and is working.

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

soap.createClient(soapWSDL, function (err, client) {
  if (err) throw err;
  console.log(client.describe() );
});


// console.log  => 
{ 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] } } }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .