This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Web Services and the fly likes Retrieving Header of a SOAP Message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Retrieving Header of a SOAP Message" Watch "Retrieving Header of a SOAP Message" New topic

Retrieving Header of a SOAP Message

Andrew Prinoli

Joined: Jan 11, 2007
Posts: 22
I create a simple axis Message whith this simple procedure :

And I think that that part of code should work ok..since if I print out the message with i.e. "msg.writeTo(System.out)" it works..

I need to retrieve the SOAP header , but I keep on getting errors (nullpointer..) while doing it with "msg.getSOAPHeader()".
It doesn't even work doing so :

How should I do that?
Thanks a lot in Advance..

Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
There is no SOAP header in the message. You shouldn't expect the getHeaders() method to return anything.

Below is a SOAP instance with a header for example.

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="" xmlns:xsd="" xmlns:xsi="">

<wsse:Security soapenv:actor="" soapenv:mustUnderstand="0" xmlns:wsse="">

<ns1:createMarketOrder soapenv:encodingStyle="" xmlns:ns1="">
<symbol xsi:type="xsd:string">AMZ</symbol>
<buy href="#id0"/>
<quantity href="#id1"/>
<multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="" xsi:type="xsd:int" xmlns:soapenc="">200</multiRef>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="" xsi:type="xsd:boolean" xmlns:soapenc="">false</multiRef>

[ November 14, 2008: Message edited by: James Clark ]
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Keep in mind, in regards to form, it is best to separate the implementation of header processing from the implementation of the actual service processing.
Have you checked out Aspose?
subject: Retrieving Header of a SOAP Message
It's not a secret anymore!