www.erpqna.com Open in urlscan Pro
176.123.5.14  Public Scan

URL: http://www.erpqna.com/creating-a-sync-integration-for-downloading-open-text-content-with-rest-api-from-sap-po-using-ap...
Submission: On January 29 via manual from NL — Scanned from NL

Form analysis 1 forms found in the DOM

GET https://www.erpqna.com/

<form method="get" class="form-search" action="https://www.erpqna.com/">
  <div class="form-group">
    <div class="input-group">
      <span class="screen-reader-text">Search for:</span>
      <input type="text" class="form-control search-query" placeholder="Search..." value="" name="s">
      <span class="input-group-btn">
        <button type="submit" class="btn btn-default" name="submit" id="searchsubmit" value="Search"><span class="glyphicon glyphicon-search"></span></button>
      </span>
    </div>
  </div>
</form>

Text Content

Toggle navigation

 * Blog
 * Preparation Guide
   * SAP MM
   * SAP HR
   * SAP BFI
   * SAP PO
   * SAP IBP
   * SAP B1
   * SAP SRM
   * SAP SM
   * SAP BO WEBI
   * More>>
 * Tutorial
   * SAP FI
   * SAP CO
   * SAP MM
   * SAP BI
   * SAP PP
   * SAP QM
   * SAP CRM
   * SAP SD
   * SAP HR
   * More>>




CREATING A SYNC INTEGRATION FOR DOWNLOADING OPEN TEXT CONTENT WITH REST API FROM
SAP PO, USING API WITH MULTIPART/FORM-DATA AUTHENTICATION

March 29, 2023November 24, 2023 webadmin


INTRODUCTION:

The purpose of this document is to develop a synchronous interface to download
content from Open Text Content Server (OTCS) using REST API. I have tried to
cover the overall design with code snippets for reference.


SCOPE:

 * Rest OTCS authentication using Content-Type: multipart/form-data (Credentials
   as a header of the multipart body) for the token (otcsticket) generation.
   
 * Parameterized Mapping for accessing the OTCS credentials from ICO.
   
 * Calling OTCS authentication lookup, accessing parameters from java mapping.
   
 * Creating DynamicConfigurationKey for rest channel Parameter from java
   mapping.
   
 * OTCS session token management is out of scope.


OVERALL DESIGN:

Sync Interface to get the Document from OpenText via PO 7.5


SOLUTION FLOW:

 1. SAP ECC calls a proxy to send the Document ID of the document in OTCS.
    
 2. PO Request java mapping receives Document ID.
    
    * Calls OTCS – Authentication API for a token (otcsticket) via REST lookup
      
    * Post ID and token to OTCS – Content API
      
 3. PO Response Java Mapping receives Document as an inputstream and maps it to
    the content field.
    
 4. Base64 content Field is sent to SAP for further processing.


REST API CONSUMED FROM OPEN TEXT CONTENT SERVER (OTCS):

 * Authentication API – /otcs/cs.exe/api/v1/auth: API needs to be called with
   credentials in Content-Type: multipart/form-data section to generate a token,
   which is called otcsticket. Otcsticket needs to be present in the header for
   content API to be called.





In Content-Type: multipart/form-data, credentials need to be present, separated
by a boundary.

 * Content API – /otcs/cs.exe/api/v1/nodes/{ID}/content: API would return the
   document as a byte stream, when called with the token and ID of the document
   in the header.

otcsticket and ID of the document in the http header


PO OBJECTS AND CODE SNIPPETS:

Data Structure

Document ID for OTCS comes as DataID from SAP. The document is returned to SAP
as Content.





ICO





Mapping (MM) & Operational mapping (OM)

Please take care of the above ICO parameter in

 * OM-> Parameters section and Request Mapping Binding section
   
 * MM -> Signature tab

Request Mapping with java mapping in the Attributes and Methods Section





public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException {

		try {

			getTrace().addDebugMessage("***OTCS-Request-JavaMapping-Start");
			
			//Get the mapping parameter from ICO
			String paramChannel = in.getInputParameters().getString("lookupChannel"); 
			String paramUserName = in.getInputParameters().getString("username"); 
			String paramPassword = in.getInputParameters().getString("password");
			String paramBoundary = in.getInputParameters().getString("boundary");
			getTrace().addDebugMessage("***OTCS-Step1-LogPramFromICO-lookupChannel:" + paramChannel + "-username:" 
				+ paramUserName + "-password:" + paramPassword +"-boundary:" +  paramBoundary);
			
			//Creating multipart/form-data for OTCS authentication
			String LINE_FEED = "\r\n";
			String ContentDisposition = "Content-Disposition: form-data; name=\"";
			String authReqFormData ="";
			authReqFormData =  LINE_FEED + paramBoundary + LINE_FEED + ContentDisposition + "username\"" + LINE_FEED 
				+ LINE_FEED + paramUserName + LINE_FEED + paramBoundary +  LINE_FEED +ContentDisposition 
				+ "password\"" + LINE_FEED + LINE_FEED + paramPassword + LINE_FEED + paramBoundary + "–-" + LINE_FEED;
			getTrace().addDebugMessage("***OTCS-Step2-multipart/form-data:" + authReqFormData);
			
			//Read message header value for Receiver 
			String paramReceiver = in.getInputHeader().getReceiverService();
			getTrace().addDebugMessage("***OTCS-Step3-ReceiverService:" + paramReceiver);
			
			//Get the OTCS rest lookup Channel Object for authentication
			Channel lookup_channel = LookupService.getChannel(paramReceiver, paramChannel);
			
			//Call rest lookup channel, with multipart/form-data payload
			SystemAccessor accessor = null;
			accessor = LookupService.getSystemAccessor(lookup_channel);
			InputStream authInputStream = new ByteArrayInputStream(authReqFormData.getBytes("UTF-8"));
			Payload authPayload = LookupService.getXmlPayload(authInputStream);
			Payload tokenOutPayload = null;
			//Call lookup
			getTrace().addDebugMessage("***OTCS-Step4-CallLookupChannel");
			tokenOutPayload = accessor.call(authPayload);
			//Parse for Lookup response for token
			InputStream authOutputStream = tokenOutPayload.getContent();
			DocumentBuilderFactory authfactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder authbuilder = authfactory.newDocumentBuilder();
			Document authdocument = authbuilder.parse(authOutputStream);
			NodeList nlticket = authdocument.getElementsByTagName("ticket");
			String tokenTicket = "Empty";
			Node node = nlticket.item(0);
			if (node != null){
				node = node.getFirstChild();
				if (node != null){
					tokenTicket = node.getNodeValue();
				}
			}
			getTrace().addDebugMessage("***OTCS-Step5-TokenFromLookup:" + tokenTicket);
						
			//Parse input stream and get DataID from SAP
			DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
			Document doc = dBuilder.parse(in.getInputPayload().getInputStream());
			String DataID = doc.getElementsByTagName("DataID").item(0).getTextContent();
			getTrace().addDebugMessage("***OTCS-Step6-DataIDFromSAP: " + DataID);
			
			//Create HTTP Header for rest call via setting DynamicConfiguration keys, that can be used in reciver channel
			DynamicConfiguration conf = in.getDynamicConfiguration();
			DynamicConfigurationKey keytokenTicket = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/REST","HeadertokenTicket");
			DynamicConfigurationKey keyDataID = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/REST","HeaderDataID");
			conf.put(keytokenTicket, tokenTicket);
			conf.put(keyDataID, DataID);

			String DummyPayload =  "DummyPayload";
			// Instantiating output stream to write at Target message
			OutputStream os = out.getOutputPayload().getOutputStream();
			// writing idoc to output stream
			os.write(DummyPayload.getBytes("UTF-8"));
			os.flush();
			os.close();
			getTrace().addDebugMessage("***OTCS-Request-JavaMapping-End");
		}
		catch (Exception e){
			getTrace().addDebugMessage(e.getMessage().toString());
			throw new StreamTransformationException(e.getMessage());
		}

	}

Response Mapping with java mapping in the Attributes and Methods Section





public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException {
		try 
		{
			getTrace().addDebugMessage("***OTCS-Respose-JavaMapping-Start");
			InputStream inputstream = in.getInputPayload().getInputStream();
			OutputStream outputstream = out.getOutputPayload().getOutputStream();
			//Copy Input Payload into Output xml
			byte[] b = new byte[inputstream.available()];
			inputstream.read(b);
			//Form Output xml
			String outputStart = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:MT_DocContent_Res xmlns:ns0=\"urn://XXXXXXXXXXX.com/OTCS/DocDownload\"><Content>";
			String outputEnd = "</Content></ns0:MT_DocContent_Res>";
			outputstream.write(outputStart.getBytes("UTF-8"));
			outputstream.write(b);
			outputstream.write(outputEnd.getBytes("UTF-8"));
			outputstream.flush();
			outputstream.close();
			getTrace().addDebugMessage("***OTCS-Respose-JavaMapping-End");
		}

		catch (Exception e)
		{
			getTrace().addDebugMessage(e.getMessage().toString());
			throw new StreamTransformationException(e.getMessage());

		}
	}

Channels

We have three channels in the flow, Such as Proxy channel from SAP, Rest
channels for Token Lookup, and document fetching from the OTCS.

Proxy – CC_OTCS_GetDoc_Proxy_Sender

Rest lookup channel – CC_OTCS_Rest_LookUp

 * URL- http://{Server}/otcs/cs.exe/api/v1/auth
   
 * Rest Operation- POST
   
 * Data Format- UTF-8


 * HTTP Headers, as below

Content-Type multipart/form-data; boundary=SapPO75FormBoundaryhahahahahahahaEND

Rest document fetch channel– CC_OTCS_Rest_Receiver

 * URL- http:// /{Server}/otcs/cs.exe/api/v1/nodes/{ID}/content
   
 * Variable Substitution-


 * Rest Operation- GET
   
 * Data Format- UTF-8
   
 * HTTP Headers, as below

otcsticket {otcsticket}

ID {ID}

ERP, SAP PO erp, SAP PO, SAP Process Orchestration. permalink.

--------------------------------------------------------------------------------


POST NAVIGATION

C_ARSOR_2302: How to Earn the SAP Ariba Sourcing Certification?
C_ARCIG_2302 Practice Test: Your Key to Become SAP Ariba Integration Associate


SEARCH

Search for:




ADS




 * Popular
 * Recent
 * 

 * IBM Watson Assistant Chatbot for UI5 Application : Step-by-step guide Jun 19,
   2021
 * List of S4HANA Credit Management Reports, Tables & Some issues we faced in
   our recent S4HANA Implementation May 10, 2020
 * SAP S/4 HANA 1909 SP01 Best Practice Content Activation in a Merged Client
   Part-1 Jul 6, 2020
 * How to Configure Custom Fiori App for SAP Transaction Code (On-Premise) on
   Central Hub Apr 22, 2020
 * S/4HANA Embedded Extended Warehouse Management (EWM) Overview Apr 17, 2020

 * C_C4H225_12 Exam Mastery: A Thorough Preparation Guide Jan 27, 2024
 * Connect SAP Web Intelligence to SAP Datasphere analytic models using OAuth
   2.0 Jan 27, 2024
 * Upload attachments in a Freestyle UI5 and CAP app Jan 22, 2024
 * SuccessFactors Career Development Planning & Mentoring Certification
   Unveiled: C_THR95_2311 Guide Jan 20, 2024
 * Study Tips: Optimizing Your Path to C_GRCAC_13 Certification Excellence Jan
   17, 2024


ARCHIVES

 * January 2024 (21)
 * December 2023 (30)
 * November 2023 (16)
 * October 2023 (17)
 * September 2023 (17)
 * August 2023 (23)
 * July 2023 (12)
 * June 2023 (23)
 * May 2023 (36)
 * April 2023 (33)
 * March 2023 (26)
 * February 2023 (21)
 * January 2023 (21)
 * December 2022 (31)
 * November 2022 (27)
 * October 2022 (24)
 * September 2022 (22)
 * August 2022 (14)
 * July 2022 (29)
 * June 2022 (24)
 * May 2022 (29)
 * April 2022 (36)
 * March 2022 (34)
 * February 2022 (19)
 * January 2022 (28)
 * December 2021 (30)
 * November 2021 (27)
 * October 2021 (30)
 * September 2021 (34)
 * August 2021 (31)
 * July 2021 (30)
 * June 2021 (46)
 * May 2021 (34)
 * April 2021 (33)
 * March 2021 (39)
 * February 2021 (25)
 * January 2021 (34)
 * December 2020 (32)
 * November 2020 (25)
 * October 2020 (28)
 * September 2020 (30)
 * August 2020 (26)
 * July 2020 (32)
 * June 2020 (28)
 * May 2020 (25)
 * April 2020 (29)
 * March 2020 (29)
 * February 2020 (24)
 * January 2020 (22)

 * Contact Us
 * Privacy Policy
 * SAP Certification

Copyright © 2018 ERP Q&A | Powered by Wordpress Theme by Colorlib Powered by
WordPress