Ok got the problem,

Posting for the benefit of everybody. This is the correct code snippet. Need
to use builder.getSOAPEnvelope and not createStAXOMBuilder API

                        OMElement documentElement =
AXIOMUtil.stringToOM(resp);
                        
                        System.out.println(documentElement);
                        //Create an XMLStreamReader to get the StAX events


                        SOAP11Factory f = new SOAP11Factory();

                        StAXSOAPModelBuilder builder =
        
OMXMLBuilderFactory.createStAXSOAPModelBuilder(f,documentElement.getXMLStrea
mReader());
                    SOAPEnvelope _returnEnv = builder.getSOAPEnvelope();

Regards,
Chandan

-----Original Message-----
From: Chandan Gupta [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 29, 2008 6:29 PM
To: [email protected]
Subject: Using AXIOM to create SOAP envelope from raw XML String

Hi,

 

I'm not sure if this is the right place to post this question, however I
will risk it. Im using AXIOM and ADB to create SOAPEnvelope from raw xml
string. I think I have the steps nailed down however im getting the
following exception

 

 

Exception in thread "main" org.apache.axiom.om.OMException

      at
org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:151)

      at
org.apache.axiom.om.impl.llom.OMElementImpl.buildNext(OMElementImpl.java:552
)

      at
org.apache.axiom.om.impl.llom.OMElementImpl.getFirstOMChild(OMElementImpl.ja
va:563)

      at
org.apache.axiom.om.impl.llom.OMElementImpl.getFirstElement(OMElementImpl.ja
va:823)

      at
org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.getHeader(SOAPEnvelopeImpl.
java:81)

 

 

Here is my code snippet.

 

ByteArrayInputStream bais = new ByteArrayInputStream(resp.getBytes());


                                    //Create an XMLStreamReader to get the
StAX events        

                                    XMLStreamReader reader =
XMLInputFactory.newInstance().createXMLStreamReader(bais);

                                    SOAP11Factory f = new SOAP11Factory();

                                    SOAPEnvelope _returnEnv;

                                    OMXMLParserWrapper wrapper =
OMXMLBuilderFactory.createStAXOMBuilder(f,reader);

 
_returnEnv=f.createSOAPEnvelope(wrapper);

                                    System.out.println(resp);

                                    //_returnEnv.setText(resp);

                                    

                                    

                                    

 
System.out.println(_returnEnv.toString());

 

Can anyone point me the error. Resp is an xml String here which is a valid
SOAP envelope.

 

Regards,

Chandan



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to