Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

SOAP <urn:Write> in Javascript

rajAdobeDev
Level 2
Level 2

Hi Team,

 

Am trying to achieve the below in adobe campaign javascript. Am able to get the session token successfully, Need some help for the below one.

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

     <soapenv:Header/> 

     <soapenv:Body> 

        <urn:Write> 

             <urn:sessiontoken></urn:sessiontoken> 

           <urn:domDoc> 

                  <rt_opt xtkschema="pl_:rt_opt"

  BUSINESS_UNIT_CD ="TEST"

  email =Test@gmail.com /> 

           </urn:domDoc> 

        </urn:Write> 

     </soapenv:Body> 

  </soapenv:Envelope>

 

Regards,

Rajshekar.

1 Accepted Solution
kapilKochar
Correct answer by
Community Advisor
Community Advisor

Hi Raj,

 

addMethod (name, action, arguments, responses, requestNodeName, responseNodeName)
 
 Write Method : Return value(s) : None
 
So you need to update your code accordingly. 
 
E.g of using ExecuteQuery method of QueryDef
 

https://docs.adobe.com/content/help/en/campaign-classic/using/configuring-campaign-classic/api/web-s...

var query = new SoapService(cnx, 'urn:xtk:queryDef');
query.addMethod("ExecuteQuery", "xtk:queryDef#ExecuteQuery",
["sessiontoken", "string", "entity", "NLElement"],
["res", "NLElement"]);

var queryRes = query.ExecuteQuery("", <queryDef operation="select" schema="nms:recipient">
<select>
<node expr="@email"/>
<node expr="@lastName"/>
<node expr="@firstName"/>
</select>
<where>
<condition expr="@email = 'joe.doe@aol.com'"/>
</where>
</queryDef>);
logInfo(queryRes[0].toXMLString())

View solution in original post

4 Replies
rajAdobeDev
Level 2
Level 2

Hi All,

 

Am getting below error :
Unspecified function library ('library' attribute) for JavaScript SOAP call 'Write' in schema 'xtk:session'.
Could anyone help for missing anything in below code:


loadLibrary('xtk:common.js')
loadLibrary('xtk:wsdlToolbox.js')
try {
logInfo("PREPARING SESSION");
var cnx = new HttpSoapConnection("http://some.com/nl/jsp/soaprouter.jsp");
try {
var session = new SoapService(cnx, 'urn:xtk:session');
try {
session.addMethod("Logon", "xtk:session#Logon",
["sessiontoken", "string", "Login", "string", "Password", "string", "Parameters", "NLElement"],
["sessionToken", "string", "sessionInfo", "NLElement", "securityToken", "string"]);
logInfo("STARTING LOGON SESSION");
var res = session.Logon("", "Test", "Test", <param/>);
logInfo("RESPONSE: " + JSON.stringify(res));
var sessionToken = res[0];
var securityToken = res[2];
cnx.addTokens(sessionToken, securityToken);
logInfo("PREPARING WRITE");
var event = new SoapService(cnx, 'urn:xtk:session');
logInfo("WRITE SESSION : " + event);
event.addMethod("Write", "xtk:session#Write",
["sessiontoken", "string", "domDoc", "NLElement"],
["res", "NLElement"]);
logInfo("STARTING OPT SESSION");
var eventRes = event.Write("",
<rt_opt
xtkschema="pl_:rt_opt"
BUSINESS_UNIT_CD ="TEST"
EXT_CONTACT_ID ="Test"
EXT_CONSUMER_ID ="Test"
EXT_SOURCE_CD ="Test"
recipientId=""
email ="abc@test.com"
OPT_SOURCE_CD =""
OPT_ID ="1603"
OPT_CHANNEL_CD ="EM"
OPT_RULE_CD =""
OPT_STATUS ="IN"
TRANSACTION_ID =""
STATUS_CD ="N"
RESUBMIT_IND ="N"
EXT_RECORD_TS =""
OPT_TS ="">
</rt_opt>);
logInfo("PARSING RESULTS");
if (null === eventRes || undefined === eventRes) {
logError("No response");
}
logInfo("EVENT RESPONSE: " + eventRes.toString())
logInfo("XML OUTPUT IS : " + eventRes.toXMLString())
} finally {
event.dispose();
logInfo("EVENT DISPOSED")
} */
} finally {
session.dispose();
logInfo("SEESSION DISPOSED")
}
} finally {
cnx.dispose();
logInfo("CNX DISPOSED")
}
} catch (e) {
logError(e);
}

Regards,

Rajshekar.

Jyoti_Y
Community Advisor
Community Advisor

Hi Raj,

You can trace your error.

1) Are you able to send request to Adobe Campaign? Are you seeing any log in Home< Monitoring< Processes List> Web log?

Print some logInfo() at the entry of Javascript.

2) If you are able to reach Adobe Campaign- that validates that sessionToken provided in your SOAP call is valid.

3) If not, then your syntax is not correct.

4) I found below line also odd: event.addMethod("Write", "xtk:session#Write",

try to replace it with event.addMethod("Write", "xtk.session.Write",

 

You can do write using: xtk.session.Write

 

Thanks.

kapilKochar
Correct answer by
Community Advisor
Community Advisor

Hi Raj,

 

addMethod (name, action, arguments, responses, requestNodeName, responseNodeName)
 
 Write Method : Return value(s) : None
 
So you need to update your code accordingly. 
 
E.g of using ExecuteQuery method of QueryDef
 

https://docs.adobe.com/content/help/en/campaign-classic/using/configuring-campaign-classic/api/web-s...

var query = new SoapService(cnx, 'urn:xtk:queryDef');
query.addMethod("ExecuteQuery", "xtk:queryDef#ExecuteQuery",
["sessiontoken", "string", "entity", "NLElement"],
["res", "NLElement"]);

var queryRes = query.ExecuteQuery("", <queryDef operation="select" schema="nms:recipient">
<select>
<node expr="@email"/>
<node expr="@lastName"/>
<node expr="@firstName"/>
</select>
<where>
<condition expr="@email = 'joe.doe@aol.com'"/>
</where>
</queryDef>);
logInfo(queryRes[0].toXMLString())

View solution in original post