I believe there's some JAXB annotations you can add (http://jaxb.java.net/guide/) to your Java mapping class to have Address map to "Address" (or, "pumpkin", for that matter) instead of "address". Part of the problem is that your POJO is not really a POJO (using proper camelCasing, shouldn't the String instance be called "address" to begin with?) Also, links #3 and #4 under "Assorted Topics" here: http://www.jroller.com/gmazza/entry/blog_article_index show how to add arbitrary headers to SOAP messages (in case the error is somehow not JAXB-related.)

HTH,
Glen

On 10/18/2011 03:55 PM, Zoltan Sziladi wrote:
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



--
Glen Mazza
Talend - http://www.talend.com/apache
Blog - http://www.jroller.com/gmazza
Twitter - glenmazza

Reply via email to