SOAP <urn:Write> in Javascript

rajAdobeDev

05-01-2020

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.

Accepted Solutions (1)

Accepted Solutions (1)

kapilKochar

MVP

12-05-2020

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())

Answers (1)

Answers (1)

rajAdobeDev

07-01-2020

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.