You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Clay Luther <cl...@cisco.com> on 2001/04/24 23:10:49 UTC

Getting XML (text) out of a Body

I am writing a message handling service and I need to extract XML from the
Body of the SOAP Envelope.  My code looks something like this:


public void axl(Envelope soapEnvelope,
                SOAPContext soapRequest,
                SOAPContext soapResponse)
        throws MessagingException, IOException
    {
        if (soapEnvelope == null)
            throw new MessagingException("Envelope is NULL");

        Body body = soapEnvelope.getBody();

        if (body == null)
            throw new MessagingException("Body is NULL");

        ....
    }


at this point, however, I'm at a little bit of loss of how I can get my XML
out of the Body object so that I can hand it to my parser for further
processing.

In effect, I want something like:

        if (body == null)
            throw new MessagingException("Body is NULL");

        Node rootnode = body.getThatRootNodeSomehow();
        Node result = parse(rootnode);

and I'm trying to figure out body.getThatRootNodeSomehow().


Thanks!

---
Clay
Cisco Systems, Inc.
claycle@cisco.com
(972) 813-5004

J'ai un regret: je ne regrette rien.




---------------------------------------------------------------------
To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
For additional commands, email: soap-user-help@xml.apache.org


Re: Getting XML (text) out of a Body

Posted by Wouter Cloetens <wo...@mind.be>.
The Envelope contains the already parsed XML in a DOM object structure.
However, you can always extract the data yourself from the request
SOAPContext object. getRootPart() will return a (JavaMail) MimeBodyPart
object, which allows you to do various things to extract the content,
e.g. as a String in the typical case of a 'text/xml' request, or as
an InputStream. Check out the JavaMail and Javabeans Activation Framework
API docs. samples/mime/MimeTest.java also has a loopProcessor example
that you might find useful.

bfn, Wouter

On Tue, Apr 24, 2001 at 04:10:49PM -0500, Clay Luther wrote:
> I am writing a message handling service and I need to extract XML from the
> Body of the SOAP Envelope.  My code looks something like this:
> 
> 
> public void axl(Envelope soapEnvelope,
>                 SOAPContext soapRequest,
>                 SOAPContext soapResponse)
>         throws MessagingException, IOException
>     {
>         if (soapEnvelope == null)
>             throw new MessagingException("Envelope is NULL");
> 
>         Body body = soapEnvelope.getBody();
> 
>         if (body == null)
>             throw new MessagingException("Body is NULL");
> 
>         ....
>     }
> 
> 
> at this point, however, I'm at a little bit of loss of how I can get my XML
> out of the Body object so that I can hand it to my parser for further
> processing.
> 
> In effect, I want something like:
> 
>         if (body == null)
>             throw new MessagingException("Body is NULL");
> 
>         Node rootnode = body.getThatRootNodeSomehow();
>         Node result = parse(rootnode);
> 
> and I'm trying to figure out body.getThatRootNodeSomehow().
> 
> 
> Thanks!
> 
> ---
> Clay
> Cisco Systems, Inc.
> claycle@cisco.com
> (972) 813-5004
> 
> J'ai un regret: je ne regrette rien.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
> For additional commands, email: soap-user-help@xml.apache.org
> 
---end quoted text---

---------------------------------------------------------------------
To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
For additional commands, email: soap-user-help@xml.apache.org


Re: Getting XML (text) out of a Body

Posted by Wouter Cloetens <wo...@mind.be>.
The Envelope contains the already parsed XML in a DOM object structure.
However, you can always extract the data yourself from the request
SOAPContext object. getRootPart() will return a (JavaMail) MimeBodyPart
object, which allows you to do various things to extract the content,
e.g. as a String in the typical case of a 'text/xml' request, or as
an InputStream. Check out the JavaMail and Javabeans Activation Framework
API docs. samples/mime/MimeTest.java also has a loopProcessor example
that you might find useful.

bfn, Wouter

On Tue, Apr 24, 2001 at 04:10:49PM -0500, Clay Luther wrote:
> I am writing a message handling service and I need to extract XML from the
> Body of the SOAP Envelope.  My code looks something like this:
> 
> 
> public void axl(Envelope soapEnvelope,
>                 SOAPContext soapRequest,
>                 SOAPContext soapResponse)
>         throws MessagingException, IOException
>     {
>         if (soapEnvelope == null)
>             throw new MessagingException("Envelope is NULL");
> 
>         Body body = soapEnvelope.getBody();
> 
>         if (body == null)
>             throw new MessagingException("Body is NULL");
> 
>         ....
>     }
> 
> 
> at this point, however, I'm at a little bit of loss of how I can get my XML
> out of the Body object so that I can hand it to my parser for further
> processing.
> 
> In effect, I want something like:
> 
>         if (body == null)
>             throw new MessagingException("Body is NULL");
> 
>         Node rootnode = body.getThatRootNodeSomehow();
>         Node result = parse(rootnode);
> 
> and I'm trying to figure out body.getThatRootNodeSomehow().
> 
> 
> Thanks!
> 
> ---
> Clay
> Cisco Systems, Inc.
> claycle@cisco.com
> (972) 813-5004
> 
> J'ai un regret: je ne regrette rien.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
> For additional commands, email: soap-user-help@xml.apache.org
> 
---end quoted text---

---------------------------------------------------------------------
To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
For additional commands, email: soap-user-help@xml.apache.org