sam store headers

Highlighted
One Star

sam store headers

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 ?
Employee

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.
Employee

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 ~
One Star

Re: sam store headers

xldai, could you give me some more details? I don't know how to do with your interceptor(how to configure, where I should put the file interceptor). Thank you.
One Star

Re: sam store headers

Hello,
Is there anyone can help me?
One Star

Re: sam store headers

Any news? I'm still waiting.
Moderator

Re: sam store headers

Hi louislinlin,

Sorry for delay!

We have reported your issue to ESB expert then come back to you as soon as we can.

Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Employee

Re: sam store headers

Hi,

For more detailed, you have to download the sam-agent source from tesb-rt-se repo on the Github, also some example for SAM in the examples project.

For interceptors and features, you may reference http://cxf.apache.org/docs/interceptors.html and http://cxf.apache.org/docs/features.html
One Star

Re: sam store headers

xldai,
Thanks for your reply. Could you give me a simple example and explain me step by step please? Or some screenshots? 
One Star

Re: sam store headers

xldai,
I dowloaded your code source and I changed it. And then I put it in the Runtime_ESBSE\container\system\org\talend\esb\sam-agent\6.1.0. But it changes nothing. Is it good for what I did? 
One Star

Re: sam store headers

xldai,
Do you have any news? I'm still waiting for you.
Employee

Re: sam store headers

Hi,
There are options which make your changed sam-agent used in the container.
1) replace the one in the container\system\... and execute command "update sam-agent" from Runtime console.
2) replace the one in the container\system\... and clean the data/ folder and restart container.
3) remove the one in the container\system\... and clean the data/ folder, then "mvn clean install" the sam-agent into local .m2 and restart container.
More info you can reference Talend help documentation and karaf website.

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read