When extracting the body from a SOAP envelope you want the second element.
The first element under the envelope should be the header, which is why you
get an exception for attempting to cast the header to a body. It may help to
have a better understanding of the anatomy of a SOAP message.
http://www.w3.org/TR/soap12-part1/ may be of some help.

-----Original Message-----
From: Asma Maalej [mailto:amaa...@laas.fr] 
Sent: Wednesday, September 23, 2009 10:48 AM
To: axis-user@ws.apache.org
Subject: access to SOAP Body Element (Axis2 API)

Hello

Using Axis2.1.4.1, and in order to recover methods name of a web service 
within a handler code, I tried to access to the SOAP message and extract 
it from the SOAPBody. Then, I tried to use "SOAPBodyElement" Class
as shown below :
*****
SOAPEnvelope soapenv = messageContext.getEnvelope();
SOAPBodyElement  soapb = (SOAPBodyElement) soapenv.getFirstElement();
String methodname = soapb.getLocalName();
************

but when I invoke the web service to which I engaged the module that 
contains the above-mentioned handler, an exception launch :
****
org.apache.axiom.soap.impl.llom.soap12.SOAP12HeaderImpl cannot be cast 
to org.apache.axiom.soap.impl.llom.SOAPBodyElement 
****

and when I tried to convert "SOAPBodyElement" to "SOAPBodyImpl" it 
launch the same exception but this time

****
org.apache.axiom.soap.impl.llom.soap12.SOAP12HeaderImpl cannot be cast 
to org.apache.axiom.soap.impl.llom.SOAPBodyImpl
****
 If you have any idea, don't hesitate to help me with, please

thanks

-- 
Asma MÂALEJ BESBES
Laboratoire LAAS - CNRS
Toulouse - France
Tèl: +33 (0)5 61 33 62 63
Mobile: +33 (0)6 72 18 36 56
E-mail: amaa...@laas.fr

Reply via email to