on 2022 May 18 11:43 AM
How to use SAP Passport for CAP model at UI level so that it is added to header of all service call.
I was following this document =SAP Passport
1, In src/index.js
const libepp = require('@sap/sapdsrpassport');
const Tools = require ('@sap/sapdsrpassport/dist/util/Tools')
const CompTypes = require ('@sap/sapdsrpassport/dist/model/ComponentTypes')
const TFlags = require ('@sap/sapdsrpassport/dist/model/TraceFlags')
let epp = new libepp.DsrPassport();
// Step 1: Create a basic DsrPassport
epp.createV3Passport(
TFlags.TraceFlags.LOW, // (NONE|LOW|MEDIUM|HIGH) Use LOW for just correlation
"DemoComponent_1", // Passport Creator ComponentName
0, // Service: 0 for "undefined"
"<dummy>", //
"action", //
11, // ActionType: 11 denotes HTTP Request
"DemoComponent_1", // Previous Component PreviousComponentName
Tools.Tools.createGUID(16), // TransactionID
" ", // In case of ABAP system Source Client, else " "
CompTypes.ComponentTypes.TRACELIB, // Corresponding Component Type (see ComponentTypes)
Tools.Tools.createGUID(16), // RootContextId
Tools.Tools.createGUID(16), // ConnectionId
1); // ConnectionCounter
// Step 2
let strEpp = epp.getPassportAsString(); // get Header Value for SAP-PASSPORT header
console.info(strEpp);
// Step 1: Create a Copy of an existing Passport as Outbound Passport
let eppCopy = new libepp.DsrPassport(); // new DsrPassport Object
eppCopy.parsePassport(strEpp); // parse header value strEpp into DsrPassport Object
// Step 2: Update relevant fields of the Outbound Passport
eppCopy.setConnectionId(Tools.Tools.createGUID(16));
eppCopy.setConnectionCount(1);
eppCopy.setPreviousComponent("DemoComponent_2");
let strHeader = "SAP-PASSPORT: " + eppCopy.getPassportAsString();
console.info(strHeader);
// Access a single SAP Passport field (e.g. TransactionId)
// Example for TransactionId
let transId = epp.getTransactionId();
console.info(transId);
// Example for ConnectionId
let connId = epp.getConnectionId()
console.info(connId);
// Example for ConnectionCounter
let connCt = epp.getConnectionCount()
console.info(connCt);
// Example for ComponentId (=== SystemId)
let compName = epp.getComponentId()
console.info(compName);
let version = epp.getVersion()
console.info(version);
let action = epp.getAction()
console.info(action)
console.info(epp.getPreviousComponentId())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
10 | |
9 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.