#1 2012-05-24 09:56:18

vnodkmar
Member
Registered: 2012-02-10
Posts: 31

sam store headers

Tags: [handler, header, sam]

Hi,
I am trying to store a particular header element 'logincb' into database. I am writing SAM event handler for it. The problem is the Event which we handle does not contain header info. How can the SoapMessage be accessed in handler ?

Offline

#2 2012-05-24 11:11:08

xldai
Talend team
Registered: 2011-10-24
Posts: 32

Re: sam store headers

Hi, vnodkmar,

Currently, the only method you can override when you impl your own EventHandler is :
    public void handleEvent(Event event){...}

That means you can't manipulate the Message or SoapMessage directly, such as get a header element. the Event class has special structure but unfortunately it has no Header mapping information which you can get for now.

Offline

#3 2012-05-24 12:02:47

xldai
Talend team
Registered: 2011-10-24
Posts: 32

Re: sam store headers

As a possible workaround, maybe you can create an interceptor which used get the header element and put it to the Message, then,  sam-agent will get it and store into DB.

import org.talend.esb.sam.agent.message.CustomInfo;

public void handleMessage(Message message) throws Fault {
   ......
   Header header = ((SoapMessage)message).getHeader(...);

   Node key = (Node)header.getObject();
   String value = headerNode.getTextContent();
   
   CustomInfo customInfo = CustomInfo.getOrCreateCustomInfo(message);
   customInfo.put(key, value);
   message.put(CustomInfo.class, customInfo);
   ......
}


and add both your interceptor and sam-agent feature into jaxws:endpoint or jaxws:client like this:
        <jaxws:interceptors>
            your interceptor
        <jaxws:interceptors>
        <jaxws:features>
            <ref bean="eventFeature"/>
        </jaxws:features>

Didn't test hopefully this workaround will work ~

Offline

Board footer

Powered by FluxBB