- HTTP
- HTTPS
If you have started using Java based HTTP sender adapter, either you might have spent some time in finding out how to pass user name and password in the query string or you might still be wondering how to pass user name and password in query string.
If you use sap-user and sap-password, you might have noticed that it is not working anymore and you would get authentication error "HTTP/1.1 401 Unauthorized".
Instead of sap-user, j_username can be used to pass username in query string.
Instead of sap-password, j_password can be used to pass password in query string.
The url should look like
http://<server>:<port>/HttpAdapter/HttpMessageServlet?interfaceNamespace=test.com&interface=Test_Out&senderService=TEST_BS&senderParty=&receiverParty=&receiverService=&qos=BE&j_username=testuser&j_password=testpwd
Additional details on Java based HTTP adapter test tool are available at PI 7.30 HTTP Java Adapter Test Tools.
Additiona details on configuring the Java HTTP sender adapter and URL details are available at AAE - Configuring the Java HTTP Adapter on the Sender Channel.
Caution: You should avoid using this method of authentication in your landscape. This short blog is written just to inform the readers on what parameter names to be used for user name and password in query string of http client that is sending request to Java HTTP adapter.
At PI 7.11 and before, the HTTP adapter is an ABAP adapter. PI 7.3 introduces a new HTTP adapter (HTTP_AAE) based on the java stack, using the java Adapter Framework.
In this blog, we will take a look at a couple of test tools that we can use to test the HTTP_AAE adapter.
Introduction
In PI 7.3, in addition to the exiting HTTP adapter in ABAP, a java adapter (HTTP_AAE) has also been added. This new java adapter uses a java service to send the payload to the AAE of PI 7.3. The java adapter also provides two different methods of sending the payload, GET and POST, therefore, the need for 2 different test tools.
One of the benefits of using the HTTP_AAE adapter is to bypass the ABAP stack during message processing, which can increase the performance by as much as 10X. In addition, this adapter is a must-use when we install a java-only PI system without ABAP.
HTTP_AAE Adapter Overview
The URL to send the payload will be generated by the test tool with the following information. This is also the URL used for POST.
sender-business-component-name
Business Component name or Business System name used in the Integrated Configuration
quality-of-service
must be either BE or EO
With GET, the following URL is generated by the test tool. It is identical to the *POST* URL, except for the last parameter:
Main-Payload-Parameter-Name
the Main Payload Parameter Name used in the HTTP_AAE communication channel configuration
the pay load
must be URL encoded so that special characters, e.g. "<" and ">" can be sent without problem.
Sample input screen:
Sample result screen, with response:
HTML code which can be copy-n-pasted to a file with a file extension of .html, e.g. http_aae_Test_730_post.html.
<html>
<script type="text/javascript">;
<!--
function button1_onclick() {
var result = "";
var payload = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
var senderNamespace = escape(document.MessageParameters.SenderNamespace.value);var reqString = "http://"
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 + "&qos=" + document.MessageParameters.Qos.value;var xhttp = new ActiveXObject("msxml2.xmlhttp");
xhttp.open ("POST", reqString, false);
document.MessageParameters.URL.value=reqString;if (document.MessageParameters.Source[0].checked == true) {
payload = document.MessageParameters.xmlData.value;
xhttp.send (payload);
}
else{
var xmlDoc = new ActiveXObject("microsoft.xmldom");
xmlDoc.async=false;
xmlDoc.load (document.MessageParameters.xmlFile.value);
xhttp.send (xmlDoc);
}
result = xhttp.responseText;
xhttp.close;
document.MessageParameters.response.value=result;
}function getFile() {
var mypath = document.MessageParameters.xmlFile.value;
var ForReading = 1;
objFSO = new ActiveXObject("Scripting.FileSystemObject");
objTextFile = objFSO.OpenTextFile(mypath, ForReading);var filearray = "";
for(var n=0;!objTextFile.AtEndOfStream;n++) {
sRead = objTextFile.ReadLine();
filearray += sRead + "\n";
}
objTextFile.Close();document.MessageParameters.xmlData.value = filearray;
}
//-->
</script>
<head></head><body>
<h3>Client HTTP_AAE Adapter Test - Post </h3>
<form name="MessageParameters">
<p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<h4>Header</h4>
<tbody>
<tr>
<td width="10%"><label>ServerHost</label> </td>
<td width="22%"><input type="text" id="host" name="Server" value="" size="20" /> </td>
<td width="10%"><label>ServerPort</label> </td>
<td width="22%"><input type="text" id="port" name="Port" value="" size="10" /> </td>
</tr>
<tr>
<td width="10%"><label>SenderService</label> </td>
<td width="22%">
<input type="text" id="senderService" name="SenderService" value="" size="40" /> </td>
<td width="10%">QOS</td>
<td width="22%">
<select id="qos" name="Qos">
<option value="BE" selected>Best Effort</option>
<option value="EO" >Exactly Once</option>
</select>
</td>
</tr>
<tr>
<td width="10%"><label>SenderInterface</label> </td>
<td width="22%">
<input type="text" id="senderInterface" name="SenderInterface" value="" size="40" /> </td>
<td width="10%"><label>SenderNamespace</label> </td>
<td width="22%">
<input type="text" id="senderNamespace" name="SenderNamespace" value="" size="40" /></td>
</tr>
</tbody>
</table>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<br>
<h4>Payload</h4>
<tbody>
<tr>
<fieldset style="padding: 2">
<td width="50%"><input type="radio" name="Source" value="Textarea" checked="checked" />Type in XML</td>
<td width="50%"><input type="radio" name="Source" value="File" />Upload File</td>
</fieldset>
</tr>
<tr>
<td width="50%"><textarea name="xmlData" rows="10" cols="60"><a>test</a></textarea></td>
<td width="50%"><input type="file" name="xmlFile" size="40" onChange="return getFile()" /> </td>
</tr>
</tbody>
</table>
<p>
<input type="button" value="Send" id="button1" name="button1" LANGUAGE="javascript" onclick="button1_onclick()" />
</p>
<hr />
<h4 align="left">Result</h4>
<p align="left">URL: <textarea rows="2" name="URL" cols="104"></textarea></p>
Response Text:
<textarea name="response" rows="5" cols="100"></textarea>
</form></body>
</html>
Sample input screen:
Sample result screen, with response:
HTML code which can be copy-n-pasted to a file with a file extension of .html, e.g. http_aae_Test_730_get.html.
<html>
<script type="text/javascript">;
<!--
function button1_onclick() {
var result = "";
var payload = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
var senderNamespace = escape(document.MessageParameters.SenderNamespace.value);var reqString = "http://"
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 + "&qos=" + document.MessageParameters.Qos.value;
reqString = reqString + "&" + document.MessageParameters.MainPayload.value + "=";
reqString = reqString + encodeURIComponent(document.MessageParameters.xmlData.value);var xhttp = new ActiveXObject("msxml2.xmlhttp");
xhttp.open ("GET", reqString, false);
document.MessageParameters.URL.value=reqString;if (document.MessageParameters.Source[0].checked == true) {
payload = document.MessageParameters.xmlData.value;
xhttp.send (payload);
}
else{
var xmlDoc = new ActiveXObject("microsoft.xmldom");
xmlDoc.async=false;
xmlDoc.load (document.MessageParameters.xmlFile.value);
xhttp.send (xmlDoc);
}
result = xhttp.responseText;
xhttp.close;
document.MessageParameters.response.value=result;
}function getFile() {
var mypath = document.MessageParameters.xmlFile.value;
var ForReading = 1;
objFSO = new ActiveXObject("Scripting.FileSystemObject");
objTextFile = objFSO.OpenTextFile(mypath, ForReading);var filearray = "";
for(var n=0;!objTextFile.AtEndOfStream;n++) {
sRead = objTextFile.ReadLine();
filearray += sRead + "\n";
}
objTextFile.Close();document.MessageParameters.xmlData.value = filearray;
}
//-->
</script>
<head></head><body>
<h3>Client HTTP_AAE Adapter Test - Get </h3>
<form name="MessageParameters">
<p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<h4>Header</h4>
<tbody>
<tr>
<td width="10%"><label>ServerHost</label> </td>
<td width="22%"><input type="text" id="host" name="Server" value="" size="20" /> </td>
<td width="10%"><label>ServerPort</label> </td>
<td width="22%"><input type="text" id="port" name="Port" value="" size="10" /> </td>
</tr>
<tr>
<td width="10%"><label>SenderService</label> </td>
<td width="22%">
<input type="text" id="senderService" name="SenderService" value="" size="40" /> </td>
<td width="10%">QOS</td>
<td width="22%">
<select id="qos" name="Qos">
<option value="BE" selected>Best Effort</option>
<option value="EO" >Exactly Once</option>
</select>
</td>
</tr>
<tr>
<td width="10%"><label>SenderInterface</label> </td>
<td width="22%">
<input type="text" id="senderInterface" name="SenderInterface" value="" size="40" /> </td>
<td width="10%"><label>SenderNamespace</label> </td>
<td width="22%">
<input type="text" id="senderNamespace" name="SenderNamespace" value="" size="40" /></td>
</tr>
</tbody>
</table>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<br>
<h4>Payload</h4>
<label>Main Payload Parameter Name:</label>
<input type="text" id="mainPayload" name="MainPayload" value="" size="40" />
<P>
<tbody>
<tr>
<fieldset style="padding: 2">
<td width="50%"><input type="radio" name="Source" value="Textarea" checked="checked" />Type in XML</td>
<td width="50%"><input type="radio" name="Source" value="File" />Upload File</td>
</fieldset>
</tr>
<tr>
<td width="50%"><textarea name="xmlData" rows="10" cols="60"><a>test</a></textarea></td>
<td width="50%"><input type="file" name="xmlFile" size="40" onChange="return getFile()" /> </td>
</tr>
</tbody>
</table>
<p>
<input type="button" value="Send" id="button1" name="button1" LANGUAGE="javascript" onclick="button1_onclick()" />
</p>
<hr />
<h4 align="left">Result</h4>
<p align="left">URL: <textarea rows="6" name="URL" cols="104"></textarea></p>
Response Text:
<textarea name="response" rows="5" cols="100"></textarea>
</form></body>
</html>
String msgID = in.getInputHeader().getMessageId();
getTrace().addWarning("msgID : " + msgID);
Response code
TransformationInput in;
String data = "";
String reqMsgID = in.getInputHeader().getRefToMessageId();
// set to dynamic config:
DynamicConfiguration conf = in.getDynamicConfiguration();
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/SOAP", reqMsgID);
if (conf != null) {
data = conf.get(key);
}
async parameter
QualityOfService=ExactlyOnce
참조 링크
http://help.sap.com/saphelp_nw04/helpdata/en/bf/27fd3b651f6a1ce10000000a11402f/frameset.htm
자바매핑 SDN 가이드 페이지
자바 매핑 샘플 : |
|
|
|
필요 Library : |
|
참고 : http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/7264
|
SAP |
System No. : 00 |
|
|
|
|
|
RFC -> GUI -> |
Message Server |
Port : 3600 |
|
Gateway |
Port : 3300 |
|
|
Application Server | Port : 3200 | ||
XI System No. : 00 | Port : 50000 | 5 : 고정값 중간 00 : System No. 끝 00 : 고정값 | |
XI System No. : 10 | Port : 51000 | ||