Expand my Community achievements bar.

SOLVED

pstrSecurityToken missing from LogOn response using node js

Avatar

Former Community Member

Hi.

I try to integrate to adobe campaign API.

I use example from Web service calls  to try receive session and security token.

Here is my sample code from node.js

var body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:xtk:session">' +

   '<soapenv:Header/><soapenv:Body><urn:Logon>' +

   '<urn:sessiontoken/> ' +

   '<urn:strLogin>username</urn:strLogin> ' +

   '<urn:strPassword>pass</urn:strPassword> ' +

   '<urn:elemParameters/>' +

'</urn:Logon></soapenv:Body></soapenv:Envelope>';

request({

   headers : {

   "Content-Type" : "text/xml; charset=utf-8",

   "SOAPAction" : "xtk:session#Logon"
   },

   uri: this.loginUrl,

   body: body,

   method: 'POST'
}, (err, response, body) => {

   console.log(err);

   console.log(body);

});

And here is body response

<?xml version='1.0'?><SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:session' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'><SOAP-ENV:Body><LogonResponse xmlns='urn:xtk:session' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><pstrSessionToken xsi:type='xsd:string'>SessionTokenHere</pstrSessionToken><pSessionInfo xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'><sessionInfo></sessionInfo></pSessionInfo></LogonResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

As you can see pstrSecurityToken tag is missing from response. So my question is, am i doing something wrong, or security and management settings dont allow security token to be sent via LogOn call.

Thank you.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

So apparently i were doing something wrong.

So to help other people with this. You don't actually need Security token to run query(on some cases).

All what you need to do is to add in request body <urn:sessionToken> tag with valid token, and do not specify in HTTP headers X-Security-Token and cookie.

Code looks like this in node JS.

var body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:xtk:queryDef">' +

   '<soapenv:Header/><soapenv:Body><urn:ExecuteQuery><urn:sessiontoken>'+this.token+'</urn:sessiontoken><urn:entity>' +

   '<queryDef operation="select" schema="nms:recipient">' +

   '<select><node expr="@email"/><node expr="@lastName"/><node expr="@firstName"/></select>' +

   '<where><condition expr="@email = \'email@gmail.com\'"/></where>' +

   '</queryDef>' +

   '</urn:entity></urn:ExecuteQuery></soapenv:Body></soapenv:Envelope>';

request({

   headers : {

   "Content-Type" : "text/xml; charset=utf-8",

   "SOAPAction" : "xtk:queryDef#ExecuteQuery"
   },

   uri: "https://neweratickets-s.neolane.net/nl/jsp/soaprouter.jsp",

   body: body,

   method: 'POST'
}, (err, response, body) => {

   console.log(err);

   console.log(body);

     //All OK here.

});

Hope this helps.

View solution in original post

1 Reply

Avatar

Correct answer by
Former Community Member

So apparently i were doing something wrong.

So to help other people with this. You don't actually need Security token to run query(on some cases).

All what you need to do is to add in request body <urn:sessionToken> tag with valid token, and do not specify in HTTP headers X-Security-Token and cookie.

Code looks like this in node JS.

var body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:xtk:queryDef">' +

   '<soapenv:Header/><soapenv:Body><urn:ExecuteQuery><urn:sessiontoken>'+this.token+'</urn:sessiontoken><urn:entity>' +

   '<queryDef operation="select" schema="nms:recipient">' +

   '<select><node expr="@email"/><node expr="@lastName"/><node expr="@firstName"/></select>' +

   '<where><condition expr="@email = \'email@gmail.com\'"/></where>' +

   '</queryDef>' +

   '</urn:entity></urn:ExecuteQuery></soapenv:Body></soapenv:Envelope>';

request({

   headers : {

   "Content-Type" : "text/xml; charset=utf-8",

   "SOAPAction" : "xtk:queryDef#ExecuteQuery"
   },

   uri: "https://neweratickets-s.neolane.net/nl/jsp/soaprouter.jsp",

   body: body,

   method: 'POST'
}, (err, response, body) => {

   console.log(err);

   console.log(body);

     //All OK here.

});

Hope this helps.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----