Page 1 of 1

Creating a Custom Message Handling

Posted: Wed Mar 13, 2024 5:27 am
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.

Re: Creating a Custom Message Handling

Posted: Fri Sep 06, 2024 7:14 pm
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