HTTP Test Tool For Multipart Form Data Submission to PI 7.3 with attachments using POST method

This is known fact that HTTP java adapter is added in the SAP PI version of 7.3 and its subsequent releases. Previously data can be sent to PI with Plain HTTP adapter using POST method only. But now with the Sender HTTP adapter of Advanced Adapter Engine, data can be dispatched to PI with both GET and POST method. The parameters introduced for this in HTTP_AAE adapter are Set Form and Set Multipart. The main aim with this parameters is to catch the data from Form submission of a webpage. This feature will be immensely helpful to fetch user data directly from the webpage without processing through another application code. I tried to use all features of this adapter by making a test tool which leverages the existing functionalities of HTTP_AAE adapter.  As the Set Form property can be used to specify the name of only one request parameter whose value is copied to the XI main payload. This is kind of drawback where all the fields of the Form is required in one single payload. The Set Multipart property may include entire fields but the data is scattered in different payloads which is not very convenient for using in the mapping. The Keep Attachments property is used to embed the attached files from the HTML Form. Please check the below screen shot for your reference.

I have created the below mentioned HTML webpage which sends the data to PI HTTP_AAE adapter by using the POST method. The Message Header part contains the data about the PI server for which the message is intended. The Multipart Payload Data part contains the data of the payload of the message.

 

The code of the above page is significantly dependent on JavaScript. Thorough java script coding the payload fields are concatenated as required. But before going into the details of the coding, please have a look at the configuration of HTTP_AAE sender adapter of SAP PI version 7.3.1. All the properties are checked under Request Details in General tab. Main Payload Parameter Name field value is given to send the data of this field to PI. This field is used to hold the concatenated data of the whole form.  Neither the modules nor the ASMA attributes are used here in the example.

 

Now please have a detailed look of the front end HTML and JavaScript Code. The JavaScript code generates the URL of the PI server dynamically using the values given in the form. It also creates the xml data from the payload fields of the Form. The Main Payload Parameter Name payloadData is not any actual field here but a hidden field used to send concatenated data to PI. Here it is tried to form xml file with concatenation but the data can be sent in any text format and later can be handled through either module or mapping to convert in XML format for mapping purpose.

<html>

<!– HTTP Client for PI 7.3.1 –>

<script type=“text/javascript”>;

<!–

window.onload = function() {

document.MessageParameters.onsubmit = submitForm;

}

      function submitForm() {

createMainPayload();

// escape “https://

var senderNamespace = escape(document.MessageParameters.SenderNamespace.value);

var reqString = https://

reqString = reqString + document.MessageParameters.Server.value+“:”;

            reqString = reqString + document.MessageParameters.Port.value + “/HttpAdapter/HttpMessageServlet?”;

            reqString = reqString + “interfaceNamespace=” + senderNamespace;

            reqString = reqString + “&interface=” + document.MessageParameters.SenderInterface.value;

            reqString = reqString + “&senderService=” + document.MessageParameters.SenderService.value;

            reqString = reqString + “&senderParty=” + document.MessageParameters.SenderParty.value;

            reqString = reqString + “&qos=” + document.MessageParameters.Qos.value;

            reqString = reqString + “&sap-user=&sap-password=”;

            reqString = reqString + “&sap-client=” + document.MessageParameters.Client.value + “&sap-language=EN”;

this.action = reqString;

}    

      function createMainPayload(){

            var payload = “”;

            payload = payload + “” + document.MessageParameters.name.value + “”;

            payload = payload + “” + document.MessageParameters.email.value + “” ;

            document.MessageParameters.payloadData.value = payload;

}

//–>

</script>

<head>

<!– Meta Tags –>

<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />

<!– CSS –>

<link rel=“stylesheet” href=“structure.css” type=“text/css” />

<link rel=“stylesheet” href=“form.css” type=“text/css” />

<link rel=“stylesheet” href=“theme.css” type=“text/css” />

</head>

<body>

<div id=“container”>

<h1><img alt=“” src=“/Users/pbhadra/workspace/HTTP_Client/src/SAP-XI-310×100.jpg”></h1><br>

<div class=“info”>

<h3>HTTP Client for PI 7.3.1</h3>

</div>

<form name=“MessageParameters” class=“wufoo” method=“POST” action=“” enctype=“multipart/form-data”>

<ul>

<li class=“complex”>

<h4>Message Header</h4>

<table border=“0” cellpadding=“0” cellspacing=“0” style=“border-collapse: collapse” width=“100%”>

<tbody>

<tr>

<td width=“10%”><label>Server Host</label></td>

<td width=“22%”><input type=“text” id=“host” name=“Server” value=“Your XI server” size= “20”/></td>

<td width=“5%”>   </td>

<td width=“10%”><label>Port</label></td>

<td width=“22%”><input type=“text” id=“port” name=“Port” value=“50000” size=“10” /></td>

</tr>

<tr>

<td width=“10%”><label>Client</label></td>

<td width=“22%”><input type=“text” id=“client” name=“Client” value=“001” size=“3” /></td>

<td width=“5%”>   </td>

<td width=“10%”><label>QOS</label></td>

<td width=“22%”><input type=“text” id=“qos” name=“Qos” value=“EO” size=“4” readonly=“readonly”/></td>

</tr>

<tr>

<td width=“10%”><label>SenderService</label></td>

<td width=“22%”><input type=“text” id=“senderService” name=“SenderService” value=“TestComponent” size=“40” /></td>

<td width=“5%”>   </td>

<td width=“10%”><label>Party</label></td>

<td width=“22%”><input type=“text” id=“senderParty” name=“SenderParty” value=“” size=“40” /></td>

</tr>

<tr>

<td width=“10%”><label>SenderInterface</label></td>

<td width=“22%”><input type=“text” id=“senderInterface” name=“SenderInterface” value=“dummy3” size=“40” /></td>

<td width=“5%”>   </td>

<td width=“10%”><label>Namespace</label></td>

<td width=“22%”><input type=“text” id=“senderNamespace” name=“SenderNamespace” value=“dummy” size=“40” /></td>

</tr>

</tbody>

</table>

</li>

<p></p>

<h4>Multipart Payload Data</h4>

<table border=“0” cellpadding=“0” cellspacing=“0” style=“border-collapse: collapse” width=“100%”>

<tbody>

<tr>

<td width=“30%”>Name<input type=“text” name=“name” value=“J.Doe” size=“25”></