ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
MARKTECH LTD
Adobe Campaign Classic
Concept for storing data through ACC API
David Garcia
A proposal thatallowsdatato be sentthroughACC¡¯sAPI(soaprouter.jsp) to store dataintocustomschemasusingJavaScriptlibrariesandcustomfunctionstohandle
requestsandstorage destination.
? David Garcia
Custom Schemas & WSDL Enrich API Library
Creating core reference custom schema
Create a customschema whichwill containcustommethodsthatwill extendourAPIandpointstothe javascriptlibrarywhich holdsall the post-processingcode tostore
the requestaccordingly,furthermore,thisschemawill logall entriesdestinedtounderlyingcustomschemas.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="UTF-8"?>
<srcSchema _cs="StoreEvent (cus)" created="2017-08-21 09:54:55.017Z"
createdBy-id="0" desc="StoreEvent" entitySchema="xtk:srcSchema" img="xtk:schema.png"
label="StoreEvent" labelSingular="StoreEvent" lastModified="2017-08-21 09:58:28.090Z" mappingType="sql"
md5="E47B48897224056C10DF42CE72E84434" modifiedBy-id="0" name="StoreEvent" namespace="cus" xtkschema="xtk:srcSchema">
<createdBy _cs="david garcia (david garcia)" />
<modifiedBy _cs="david garcia (david garcia)" /
<element autopk="true" desc="StoreEvent" label="StoreEvent" labelSingular="StoreEvent" name="StoreEvent">
<attribute label="origin" name="origin" type="string" />
<attribute label="destinationId" name="destinationId" type="int64" />
<attribute label="destinationSchema" name="destinationSchema" type="string" />
<attribute label="created" name="created" type="datetime" />
</element>
<methods>
<method library="cus:PushStoreEvent" name="PushStoreEvent" static="true">
<help>Insert an event.</help>
<parameters>
<param desc="Event." inout="in" name="domEvent" type="DOMDocument" />
<param desc="Status" inout="out" name="status" type="string" />
</parameters>
</method>
</methods>
</srcSchema>
lines15-23: declarationof methodsincustomschema.
library: value pointsto JavaScriptlibrarycontainingfunctionstoexecute.
name: value containingfunctiontoexecute.
? David Garcia
(WSDL) Web Service Definition Library
Once custom schemahasbeencreatedanddeployed,aWSDL file ismade available containingcustommethods andbindstoACC¡¯sdefaultAPI.
? David Garcia
Custom Storage Schema(scores)
The followingschemawill store datadestinedfor scoresrequest.Lines22-26 definedan:1linkbetweenrequestsandrecipient,hence,arecipientcanbe assignedmultiple
scoresrecords.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<srcSchema _cs="scores (cus)" created="2017-08-17 09:57:51.933Z" createdBy-id="0"
desc="scores" entitySchema="xtk:srcSchema" img="xtk:activities/signal.png"
label="scores" labelSingular="scores" lastModified="2017-09-11 13:47:36.947Z"
mappingType="sql" md5="4F76944F562FC722DB77184831AFD129" modifiedBy-id="0"
name="scores" namespace="cus" xtkschema="xtk:srcSchema">
<createdBy _cs="david garcia (david garcia)"/>
<modifiedBy _cs="david garcia (david garcia)"/>
<element autopk="true" desc="scores" img="xtk:activities/signal.png" label="scores"
labelSingular="scores" name="scores">
<attribute label="member_id" name="member_id" type="int64"/>
<attribute label="score_id" name="score_id" type="string"/>
<attribute label="dateOfCompletion" name="dateOfCompletion" type="datetime"/>
<attribute label="dateOfRecurrence" name="dateOfRecurrence" type="datetime"/>
<attribute label="percentageComplete" name="percentageComplete" type="long"/>
<attribute label="status" name="status" type="string"/>
<attribute label="created" name="created" type="datetime"/>
<element integrity="define" label="scores-recipient" name="scores-recipient"
target="nms:recipient" type="link">
<join xpath-dst="@member_id" xpath-src=/slideshow/neolane-api-custom-soap-request-handler/140021892/"@member_id"/>
</element>
</element>
</srcSchema>
Member_idservesasa key and will be usedtocreate a joinbetweenthisschemaandrecipient schema;anadditional index canbe addedonthisfieldforperformance.
1
2
3
<dbindex name="member_id" unique="false">
<keyfield xpath=/slideshow/neolane-api-custom-soap-request-handler/140021892/"@member_id"/>
</dbindex>
? David Garcia
JavaScript Libraries & Functions
JavaScript Libraries (cus:PushStoreEvent)
The followingscriptisexecuteduponreceivingSOAPrequestcontains cus:StoreEvent#PushStoreEventasAction.Itloadsan extralibrarycontainingwritingmethodsforto
handle multiple customstorage schemas.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//reference functions which write data into tables
loadLibrary("cus:storeFunctions");
//function to parse SOAP request
function cus_StoreEvent_PushStoreEvent(request)
{
var xmlMessage = new XML(request);
var schema = xmlMessage.schema;
var created = formatDate(new Date(), '%4Y-%2M-%2D %2H:%2N:%2S');
var origin = xmlMessage.origin;
if (schema = "scores") {
storeScores(xmlMessage);
}
//return primary key of inserted record
var latestEntry = sqlSelect("Records,id:string","SELECT MAX(i"+schema+"id) as newRecord FROM cus"+schema+" where
tscreated='"+created+"'");
//log request
xtk.session.Write(<StoreEvent xtkschema="cus:StoreEvent" origin ={origin} destinationSchema ={schema} destinationId
={latestEntry.Records.id} created ={created} _operation="insert" />);
/**debug var f = new File("c:/file.txt")
f.open("a")
f.writeln(xmlMessage.toXMLString())
f.close()
**/
//return request response
return("success:"+schema+":"+latestEntry.Records.id);
}
? David Garcia
JavaScript Libraries (cus:storeFunctions)
The followingfunctionisexecutedandreferencedbycus:PushStoreEvent upontrue conditionmet if(schema= "scores") {storeScores(xmlMessage);}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function storeScores(xmlMessage)
{
var MEMBER_ID = parseInt(xmlMessage.member_id);
var SCORE_ID = xmlMessage.score_id;
var DATE_OF_COMPLETION = xmlMessage.dateOfCompletion;
var DATE_OF_RECURRENCE = xmlMessage.dateOfRecurrence;
var PERCENTAGE_COMPLETED = xmlMessage.percentageComplete;
var STATUS = xmlMessage.status
var CREATED = formatDate(new Date(), '%4Y-%2M-%2D %2H:%2N:%2S');
xtk.session.Write(<scores xtkschema="cus:scores" member_id ={MEMBER_ID}
score_id ={SCORE_ID}
dateOfCompletion ={DATE_OF_COMPLETION}
dateOfRecurrence ={DATE_OF_RECURRENCE}
percentageComplete ={PERCENTAGE_COMPLETED}
status ={STATUS}
created ={CREATED}
_operation="insert" />);
}
Write isa data APImethodthatallowsACCto store data intoschemas,inthiscase,data parsedfromthe SOAPrequestisconverted intoanXML objectandnode valuesare
assignedtolocal variables,consecutivelywrittenintothe customschema named¡°scores¡±.
? David Garcia
SOAP Request, Client & Database
SOAP Format Structure
The followingSOAPcall requestsdatacontainedinthe ctx contexttobe storedina customschemacalled¡°scores¡±.The methodtotriggeristhe value inthe SOAPAction
optionprovidedbythe SOAPclientandthe endpoint isthe followingURL inline 1 which representsACC¡¯s API.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
POST http://ec2-18-222-255-12.us-east-2.compute.amazonaws.com/nl/jsp/soaprouter.jsp HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: cus:StoreEvent#PushStoreEvent
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:cus:StoreEvent">
<soapenv:Header/>
<soapenv:Body>
<urn:PushStoreEvent>
<urn:sessiontoken>AC7/PW</urn:sessiontoken>
<urn:domEvent>
<ctx>
<origin>scoreMicroService</origin>
<schema>scores</schema>
<member_id>5316191164430650570</member_id>
<score_id>1</score_id>
<dateOfCompletion>2019-04-03T09:00:00</dateOfCompletion>
<dateOfRecurrence>2019-04-03T09:00:00</dateOfRecurrence>
<percentageComplete>50</percentageComplete>
<status>1</status>
</ctx>
</urn:domEvent>
</urn:PushStoreEvent>
</soapenv:Body>
</soapenv:Envelope>
? David Garcia
SOAP response
Once ACC¡¯sAPIconsumesthe request,itreturnsthe destinationschemaandthe primarykeyof the recordinserted;thisishandledbythe JavaScriptlibrary
cus:PushStoreEvent
? David Garcia
Schema Table Records
Recordsof logsstoredinthe StoreEvent reference core table
Recordsof data storedfromsoaprequeststocustom scoresschema
? David Garcia
Database Table Records
Recordsas seenonthe postgresdatabase forcus:StoreEventschema
? David Garcia
Conclusion
The proof of conceptservesasa pointof entryfor data meantto be storedto customschemasinAdobe CampaignClassic,customJavaScriptlibrariescanbe extendedto
cater for multiplecustomtablesandrequestscanbe processedinparallel.

More Related Content

Neolane API Custom SOAP request handler

  • 1. MARKTECH LTD Adobe Campaign Classic Concept for storing data through ACC API David Garcia A proposal thatallowsdatato be sentthroughACC¡¯sAPI(soaprouter.jsp) to store dataintocustomschemasusingJavaScriptlibrariesandcustomfunctionstohandle requestsandstorage destination.
  • 2. ? David Garcia Custom Schemas & WSDL Enrich API Library Creating core reference custom schema Create a customschema whichwill containcustommethodsthatwill extendourAPIandpointstothe javascriptlibrarywhich holdsall the post-processingcode tostore the requestaccordingly,furthermore,thisschemawill logall entriesdestinedtounderlyingcustomschemas. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <?xml version="1.0" encoding="UTF-8"?> <srcSchema _cs="StoreEvent (cus)" created="2017-08-21 09:54:55.017Z" createdBy-id="0" desc="StoreEvent" entitySchema="xtk:srcSchema" img="xtk:schema.png" label="StoreEvent" labelSingular="StoreEvent" lastModified="2017-08-21 09:58:28.090Z" mappingType="sql" md5="E47B48897224056C10DF42CE72E84434" modifiedBy-id="0" name="StoreEvent" namespace="cus" xtkschema="xtk:srcSchema"> <createdBy _cs="david garcia (david garcia)" /> <modifiedBy _cs="david garcia (david garcia)" / <element autopk="true" desc="StoreEvent" label="StoreEvent" labelSingular="StoreEvent" name="StoreEvent"> <attribute label="origin" name="origin" type="string" /> <attribute label="destinationId" name="destinationId" type="int64" /> <attribute label="destinationSchema" name="destinationSchema" type="string" /> <attribute label="created" name="created" type="datetime" /> </element> <methods> <method library="cus:PushStoreEvent" name="PushStoreEvent" static="true"> <help>Insert an event.</help> <parameters> <param desc="Event." inout="in" name="domEvent" type="DOMDocument" /> <param desc="Status" inout="out" name="status" type="string" /> </parameters> </method> </methods> </srcSchema> lines15-23: declarationof methodsincustomschema. library: value pointsto JavaScriptlibrarycontainingfunctionstoexecute. name: value containingfunctiontoexecute.
  • 3. ? David Garcia (WSDL) Web Service Definition Library Once custom schemahasbeencreatedanddeployed,aWSDL file ismade available containingcustommethods andbindstoACC¡¯sdefaultAPI.
  • 4. ? David Garcia Custom Storage Schema(scores) The followingschemawill store datadestinedfor scoresrequest.Lines22-26 definedan:1linkbetweenrequestsandrecipient,hence,arecipientcanbe assignedmultiple scoresrecords. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 <srcSchema _cs="scores (cus)" created="2017-08-17 09:57:51.933Z" createdBy-id="0" desc="scores" entitySchema="xtk:srcSchema" img="xtk:activities/signal.png" label="scores" labelSingular="scores" lastModified="2017-09-11 13:47:36.947Z" mappingType="sql" md5="4F76944F562FC722DB77184831AFD129" modifiedBy-id="0" name="scores" namespace="cus" xtkschema="xtk:srcSchema"> <createdBy _cs="david garcia (david garcia)"/> <modifiedBy _cs="david garcia (david garcia)"/> <element autopk="true" desc="scores" img="xtk:activities/signal.png" label="scores" labelSingular="scores" name="scores"> <attribute label="member_id" name="member_id" type="int64"/> <attribute label="score_id" name="score_id" type="string"/> <attribute label="dateOfCompletion" name="dateOfCompletion" type="datetime"/> <attribute label="dateOfRecurrence" name="dateOfRecurrence" type="datetime"/> <attribute label="percentageComplete" name="percentageComplete" type="long"/> <attribute label="status" name="status" type="string"/> <attribute label="created" name="created" type="datetime"/> <element integrity="define" label="scores-recipient" name="scores-recipient" target="nms:recipient" type="link"> <join xpath-dst="@member_id" xpath-src=/slideshow/neolane-api-custom-soap-request-handler/140021892/"@member_id"/> </element> </element> </srcSchema> Member_idservesasa key and will be usedtocreate a joinbetweenthisschemaandrecipient schema;anadditional index canbe addedonthisfieldforperformance. 1 2 3 <dbindex name="member_id" unique="false"> <keyfield xpath=/slideshow/neolane-api-custom-soap-request-handler/140021892/"@member_id"/> </dbindex>
  • 5. ? David Garcia JavaScript Libraries & Functions JavaScript Libraries (cus:PushStoreEvent) The followingscriptisexecuteduponreceivingSOAPrequestcontains cus:StoreEvent#PushStoreEventasAction.Itloadsan extralibrarycontainingwritingmethodsforto handle multiple customstorage schemas. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 //reference functions which write data into tables loadLibrary("cus:storeFunctions"); //function to parse SOAP request function cus_StoreEvent_PushStoreEvent(request) { var xmlMessage = new XML(request); var schema = xmlMessage.schema; var created = formatDate(new Date(), '%4Y-%2M-%2D %2H:%2N:%2S'); var origin = xmlMessage.origin; if (schema = "scores") { storeScores(xmlMessage); } //return primary key of inserted record var latestEntry = sqlSelect("Records,id:string","SELECT MAX(i"+schema+"id) as newRecord FROM cus"+schema+" where tscreated='"+created+"'"); //log request xtk.session.Write(<StoreEvent xtkschema="cus:StoreEvent" origin ={origin} destinationSchema ={schema} destinationId ={latestEntry.Records.id} created ={created} _operation="insert" />); /**debug var f = new File("c:/file.txt") f.open("a") f.writeln(xmlMessage.toXMLString()) f.close() **/ //return request response return("success:"+schema+":"+latestEntry.Records.id); }
  • 6. ? David Garcia JavaScript Libraries (cus:storeFunctions) The followingfunctionisexecutedandreferencedbycus:PushStoreEvent upontrue conditionmet if(schema= "scores") {storeScores(xmlMessage);} 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 function storeScores(xmlMessage) { var MEMBER_ID = parseInt(xmlMessage.member_id); var SCORE_ID = xmlMessage.score_id; var DATE_OF_COMPLETION = xmlMessage.dateOfCompletion; var DATE_OF_RECURRENCE = xmlMessage.dateOfRecurrence; var PERCENTAGE_COMPLETED = xmlMessage.percentageComplete; var STATUS = xmlMessage.status var CREATED = formatDate(new Date(), '%4Y-%2M-%2D %2H:%2N:%2S'); xtk.session.Write(<scores xtkschema="cus:scores" member_id ={MEMBER_ID} score_id ={SCORE_ID} dateOfCompletion ={DATE_OF_COMPLETION} dateOfRecurrence ={DATE_OF_RECURRENCE} percentageComplete ={PERCENTAGE_COMPLETED} status ={STATUS} created ={CREATED} _operation="insert" />); } Write isa data APImethodthatallowsACCto store data intoschemas,inthiscase,data parsedfromthe SOAPrequestisconverted intoanXML objectandnode valuesare assignedtolocal variables,consecutivelywrittenintothe customschema named¡°scores¡±.
  • 7. ? David Garcia SOAP Request, Client & Database SOAP Format Structure The followingSOAPcall requestsdatacontainedinthe ctx contexttobe storedina customschemacalled¡°scores¡±.The methodtotriggeristhe value inthe SOAPAction optionprovidedbythe SOAPclientandthe endpoint isthe followingURL inline 1 which representsACC¡¯s API. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 POST http://ec2-18-222-255-12.us-east-2.compute.amazonaws.com/nl/jsp/soaprouter.jsp HTTP/1.1 Content-Type: text/xml; charset=utf-8 SOAPAction: cus:StoreEvent#PushStoreEvent <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:cus:StoreEvent"> <soapenv:Header/> <soapenv:Body> <urn:PushStoreEvent> <urn:sessiontoken>AC7/PW</urn:sessiontoken> <urn:domEvent> <ctx> <origin>scoreMicroService</origin> <schema>scores</schema> <member_id>5316191164430650570</member_id> <score_id>1</score_id> <dateOfCompletion>2019-04-03T09:00:00</dateOfCompletion> <dateOfRecurrence>2019-04-03T09:00:00</dateOfRecurrence> <percentageComplete>50</percentageComplete> <status>1</status> </ctx> </urn:domEvent> </urn:PushStoreEvent> </soapenv:Body> </soapenv:Envelope>
  • 8. ? David Garcia SOAP response Once ACC¡¯sAPIconsumesthe request,itreturnsthe destinationschemaandthe primarykeyof the recordinserted;thisishandledbythe JavaScriptlibrary cus:PushStoreEvent
  • 9. ? David Garcia Schema Table Records Recordsof logsstoredinthe StoreEvent reference core table Recordsof data storedfromsoaprequeststocustom scoresschema
  • 10. ? David Garcia Database Table Records Recordsas seenonthe postgresdatabase forcus:StoreEventschema
  • 11. ? David Garcia Conclusion The proof of conceptservesasa pointof entryfor data meantto be storedto customschemasinAdobe CampaignClassic,customJavaScriptlibrariescanbe extendedto cater for multiplecustomtablesandrequestscanbe processedinparallel.