Creating a Custom Message Handling

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
caseywhite
Posts: 192
Joined: Thu May 26, 2016 1:17 am

Creating a Custom Message Handling

Post by caseywhite »

Following on from a post I created yesterday, it seems like the AGENT_INCLUDE.txt doesn't let you add the HTTP header because you can't get access to the currentMessageContext.

The following documentation indicates you can create a custom message handler.
https://docs.lansa.com/14/en/lansa093/i ... %7C_____17

My thought is that I can do this and add the following code to it. I can't add this code to AGENT_INCLUDE.TXT because getCurrentContext returns null.

org.apache.axis.MessageContext msgContext = org.apache.axis.MessageContext.getCurrentContext();
if (msgContext != null)
{
java.util.Hashtable userHeaderTable = (java.util.Hashtable) msgContext.getProperty(org.apache.axis.transport.http.HTTPConstants.REQUEST_HEADERS);
}
userHeaderTable.put("Authorization", "Bearer MYBEARERTOKEN");


Has anyone implemented custom message handling for SOAP? If so, would you care to share some tips.
cesarrafael
Posts: 32
Joined: Tue Dec 01, 2015 3:44 am

Re: Creating a Custom Message Handling

Post by cesarrafael »

Hi Casey,

This probably comes to late, however we implemented headers using AGENT_INCLUDE with something like this:
*
Add Request header
*/

/* stub._setProperty ( org.apache.axis.MessageContext.HTTP_TRANSPORT_VERSION ,
org.apache.axis.transport.http.HTTPConstants.HEADER_PROTOCOL_V10 ) ;
*/

org.apache.axis.utils.LockableHashtable headers = new org.apache.axis.utils.LockableHashtable();
/* Valor the Autenticação para ambiente UAT/DEV */
headers.put("x-Gateway-APIKey","myAPIKeyValueHere");
stub._setProperty ( org.apache.axis.transport.http.HTTPConstants.REQUEST_HEADERS, headers ) ;


There's some issues regarding java versions but it should work with jdk1.8.0_131
HTH
Post Reply