Hello,

I would like to request some help about how to add a "From" header to a SOAP
message.

I have created an interceptor inheriting from AbstractSoapInterceptor. In
the handleMessage method I check if the message is outgoing, and if it is, I
try to add a new header.
In order to create the header, I have the following class:

public class FromHeader {
    private String Address;

    public FromHeader() {}

    public void setAddress(String add) {
        this.Address = add;
    }

    public String getAddress() {
        return this.Address;
    }
}

To add the header in the handleMessage method, I use the following code:

Header fromHeader = null;
try {
FromHeader fh = new FromHeader();
fh.setAddress("http://clienturi.org/sampleAddress";);
fromHeader = new Header(new QName("http://www.w3.org/2005/08/addressing";,
"HI"), fh,
new JAXBDataBinding(FromHeader.class));
} catch (JAXBException ex) {
Logger.getLogger(AddAddressInterceptor.class.getName()).log(Level.SEVERE,
null, ex);
}
List<Header> soapHeaders = message.getHeaders();

soapHeaders.add(fromHeader);

When this message arrives to the server, it does not arrive correctly,
because the "Address" of the class FromHeader changes to "address". Because
of this, the message does not arrive, since the server send error code 400.
Notice how I have "HI" for now as the second parameter of the Header. This
is because it is supposed to be "From", as I said, but then it does not even
arrive to the server. I changed it to "HI" to at least see the result on
server side. Apart from this, I think the message arrives correctly.

So my question is, how can I make sure, that the "Address" property of my
FromHeader class arrives as "Address" instead of "address"? (At least this
is the only problem I can think of why it is not working).

Thank you in advance for the help!

Kind regards,
Zoltán

Reply via email to