You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Alexander Rosemann <al...@gmail.com> on 2009/11/09 10:03:17 UTC
remove element from soap body
Hi,
I was wondering what's the best way to alter a soap body within a
handler. I have the soap body (SOAPBody body =
msgCtx.getEnvelope().getBody();) and can navigate though it's elements
but don't know how to alter (i.e. remove) a certain element.
Since I haven't found anything on the web, I was wondering whether
somebody tried to achieve the same and could point me into the right
direction.
I'm using Axis2 1.4.1.
Thanks in advance,
Alex
Re: remove element from soap body
Posted by Alexander Rosemann <al...@gmail.com>.
Hi Isuru,
Thanks for your help. It works!
In case someone else encounters a similar issue, that's how I did it
(removes the very first element of the SOAP body):
SOAPBody body = oMessageContext.getEnvelope().getBody();
OMElement first = body.getFirstElement();
OMElement second = first.getFirstElement();
// remove the first element from the body
first.detach();
// add the request element to the body
body.addChild(second);
Regards,
-Alex
Isuru Suriarachchi wrote:
> Hi Alex,
>
> Use omElement.detach() method..
>
> Thanks,
> ~Isuru
>
> On Mon, Nov 9, 2009 at 2:33 PM, Alexander Rosemann
> <alexander.rosemann@gmail.com <ma...@gmail.com>> wrote:
>
> Hi,
>
> I was wondering what's the best way to alter a soap body within a
> handler. I have the soap body (SOAPBody body =
> msgCtx.getEnvelope().getBody();) and can navigate though it's
> elements but don't know how to alter (i.e. remove) a certain element.
>
> Since I haven't found anything on the web, I was wondering whether
> somebody tried to achieve the same and could point me into the right
> direction.
>
> I'm using Axis2 1.4.1.
>
> Thanks in advance,
> Alex
>
>
>
>
> --
> Senior Software Engineer,
> WSO2 Inc. http://wso2.org/
> Blog : http://isurues.wordpress.com/
--
DI(FH) Alexander Rosemann
open source based software solutions
Naunspitzweg 3 | 6341 Ebbs | Austria
mobile: +43-681-10337082 | email: alexander.rosemann@gmail.com
Re: remove element from soap body
Posted by Isuru Suriarachchi <is...@gmail.com>.
Hi Alex,
Use omElement.detach() method..
Thanks,
~Isuru
On Mon, Nov 9, 2009 at 2:33 PM, Alexander Rosemann <
alexander.rosemann@gmail.com> wrote:
> Hi,
>
> I was wondering what's the best way to alter a soap body within a handler.
> I have the soap body (SOAPBody body = msgCtx.getEnvelope().getBody();) and
> can navigate though it's elements but don't know how to alter (i.e. remove)
> a certain element.
>
> Since I haven't found anything on the web, I was wondering whether somebody
> tried to achieve the same and could point me into the right direction.
>
> I'm using Axis2 1.4.1.
>
> Thanks in advance,
> Alex
>
>
--
Senior Software Engineer,
WSO2 Inc. http://wso2.org/
Blog : http://isurues.wordpress.com/