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 va...@bull.net on 2003/12/09 15:41:26 UTC
SOAP to DOM
In a handler (axis BasicHandler type), I need to transform the soap part of
the message into a Document object
I use the javax.xml.transform.Transformer and I get the Document object.
But this Document is full of "\n" and sometimes "\r" or spaces !!!
It's not very easy to use : is there any solution to get a "clean" Document
object with only the meaningful elements of the SOAPPart ?
Valerie
Re: SOAP to DOM
Posted by Christoph Tratter <tr...@dbai.tuwien.ac.at>.
Hi!
The whole thing can be much simplified if you want the SOAPEnvelope (not
only the body of it) in the current context (request or response):
void invoke(MessageContext msgContext)
{
try
{
org.apache.axis.Message testMsg = context.getCurrentMessage();
org.w3c.Element element = testMsg.getSOAPEnvelope().getAsDOM();
}
catch ( Exception ex )
{
throw new AxisFault("could not get body.");
}
...
}
regards,
Christoph
Christoph Tratter wrote:
> Hi Valerie!
>
> You can try something like this:
> In the method invoke of your handler (as it extends BasicHandler) you
> have the following signature:
>
> void invoke(MessageContext msgContext)
>
> So you can try something like:
>
> void invoke(MessageContext msgContext)
> {
> org.apache.axis.Message testMsg = context.getRequestMessage();
> //Or ResponseMessage if getPastPivot() is true
>
> org.apache.axis.SOAPPart soapPart;
> soapPart = (org.apache.axis.SOAPPart)testMsg.getSOAPPart();
> try
> {
> org.apache.axis.message.SOAPBody body;
> body = (org.apache.axis.message.SOAPBody)
> soapPart.getAsSOAPEnvelope().getBody();
> org.w3c.Element element = body.getAsDOM();
> //or: org.w3c.Document doc = body.getAsDocument();
> }
> catch ( Exception ex )
> {
> throw new AxisFault("could not get body.");
> }
> ...
> }
>
Re: SOAP to DOM
Posted by Christoph Tratter <tr...@dbai.tuwien.ac.at>.
Hi Valerie!
You can try something like this:
In the method invoke of your handler (as it extends BasicHandler) you
have the following signature:
void invoke(MessageContext msgContext)
So you can try something like:
void invoke(MessageContext msgContext)
{
org.apache.axis.Message testMsg = context.getRequestMessage();
//Or ResponseMessage if getPastPivot() is true
org.apache.axis.SOAPPart soapPart;
soapPart = (org.apache.axis.SOAPPart)testMsg.getSOAPPart();
try
{
org.apache.axis.message.SOAPBody body;
body = (org.apache.axis.message.SOAPBody)
soapPart.getAsSOAPEnvelope().getBody();
org.w3c.Element element = body.getAsDOM();
//or: org.w3c.Document doc = body.getAsDocument();
}
catch ( Exception ex )
{
throw new AxisFault("could not get body.");
}
...
}
regards,
Christoph
valerie.bauche@bull.net wrote:
> In a handler (axis BasicHandler type), I need to transform the soap part of
> the message into a Document object
> I use the javax.xml.transform.Transformer and I get the Document object.
> But this Document is full of "\n" and sometimes "\r" or spaces !!!
> It's not very easy to use : is there any solution to get a "clean" Document
> object with only the meaningful elements of the SOAPPart ?
>
> Valerie
>
>
Re: SOAP to DOM
Posted by Jeff Greif <jg...@alumni.princeton.edu>.
try document.getDocumentElement().normalize()
Jeff
----- Original Message -----
From: <va...@bull.net>
To: <ax...@ws.apache.org>
Sent: Tuesday, December 09, 2003 6:41 AM
Subject: SOAP to DOM
> In a handler (axis BasicHandler type), I need to transform the soap part
of
> the message into a Document object
> I use the javax.xml.transform.Transformer and I get the Document object.
> But this Document is full of "\n" and sometimes "\r" or spaces !!!
...