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 Rubén Naranjo Izquierdo <rn...@alumnos.upm.es> on 2006/01/18 18:30:14 UTC

[Axis2] Converting from XmlObject to OMElement

   Hi all,

   I need to insert some information in SOAP Header field. In fact I need to 
insert a class created by wsdl2java which extends 
org.apache.xmlbeans.XmlObject. To do so I try the next on my PortType's stub:

(...)
SOAPHeaderBlock headBlock = envelope.getHeader().addHeaderBlock(...);
headBlock.addChild(toOM(myType))
(...)

private OMElement toOM(XmlObject param) {
	StAXOMBuilder builder = new StAXOMBuilder(OMAbstractFactory.getOMFactory(), 
new StreamWrapper(param.newXMLStreamReader()));
	OMElement documentElement = builder.getDocumentElement();
	((OMNodeEx) documentElement).setParent(null);
	return documentElement;
}

   Depending on the class I use when calling "toOM", I get a 
"java.lang.IllegalStateException", an "org.apache.axis2.om.OMException", or 
just works fine (as you may suppose, it works fine with the classes I don't 
need)

   What am I doing wrong? Is that the correct way to convert from XmlObject to 
OMElement?

   Thank you in advance,

     Rubén

Re: [Axis2] Converting from XmlObject to OMElement

Posted by Davanum Srinivas <da...@gmail.com>.
Ruben,

Please log a bug with your code, we will try with latest SVN to see if
it has problems and try to fix it.

thanks,
dims

On 1/19/06, Rubén Naranjo Izquierdo <rn...@alumnos.upm.es> wrote:
>    I forgot to attach the stacktrace:
>
>
> org.apache.axis2.om.OMException
>         at org.apache.axis2.om.impl.llom.builder.StAXOMBuilder.next(StAXOMBuilder.java:273)
>         at org.apache.axis2.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
>         at org.apache.axis2.om.impl.llom.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:289)
>         at org.objectweb.ResponseHandlerPortTypeStub.toOM(ResponseHandlerPortTypeStub.java:162)
>         at org.objectweb.ResponseHandlerPortTypeStub.toEnvelope(ResponseHandlerPortTypeStub.java:176)
>         at org.objectweb.ResponseHandlerPortTypeStub.contents(ResponseHandlerPortTypeStub.java:102)
>         at org.objectweb.ResponseHandlerTest.main(ResponseHandlerTest.java:31)
>
>    I really need help. I need to insert that info, but I can't... Any work around at least?
>
>    Thanks,
>
>      Ruben
>
>
> On Wednesday 18 January 2006 18:30, Rubén Naranjo Izquierdo wrote:
> >    Hi all,
> >
> >    I need to insert some information in SOAP Header field. In fact I need
> > to insert a class created by wsdl2java which extends
> > org.apache.xmlbeans.XmlObject. To do so I try the next on my PortType's
> > stub:
> >
> > (...)
> > SOAPHeaderBlock headBlock = envelope.getHeader().addHeaderBlock(...);
> > headBlock.addChild(toOM(myType))
> > (...)
> >
> > private OMElement toOM(XmlObject param) {
> >       StAXOMBuilder builder = new
> > StAXOMBuilder(OMAbstractFactory.getOMFactory(), new
> > StreamWrapper(param.newXMLStreamReader()));
> >       OMElement documentElement = builder.getDocumentElement();
> >       ((OMNodeEx) documentElement).setParent(null);
> >       return documentElement;
> > }
> >
> >    Depending on the class I use when calling "toOM", I get a
> > "java.lang.IllegalStateException", an "org.apache.axis2.om.OMException", or
> > just works fine (as you may suppose, it works fine with the classes I don't
> > need)
> >
> >    What am I doing wrong? Is that the correct way to convert from XmlObject
> > to OMElement?
> >
> >    Thank you in advance,
> >
> >      Rubén
>


--
Davanum Srinivas : http://wso2.com/blogs/

Re: [Axis2] Converting from XmlObject to OMElement

Posted by Rubén Naranjo Izquierdo <rn...@alumnos.upm.es>.
   I forgot to attach the stacktrace:


org.apache.axis2.om.OMException
	at org.apache.axis2.om.impl.llom.builder.StAXOMBuilder.next(StAXOMBuilder.java:273)
	at org.apache.axis2.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
	at org.apache.axis2.om.impl.llom.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:289)
	at org.objectweb.ResponseHandlerPortTypeStub.toOM(ResponseHandlerPortTypeStub.java:162)
	at org.objectweb.ResponseHandlerPortTypeStub.toEnvelope(ResponseHandlerPortTypeStub.java:176)
	at org.objectweb.ResponseHandlerPortTypeStub.contents(ResponseHandlerPortTypeStub.java:102)
	at org.objectweb.ResponseHandlerTest.main(ResponseHandlerTest.java:31)

   I really need help. I need to insert that info, but I can't... Any work around at least?

   Thanks,

     Ruben


On Wednesday 18 January 2006 18:30, Rubén Naranjo Izquierdo wrote:
>    Hi all,
>
>    I need to insert some information in SOAP Header field. In fact I need
> to insert a class created by wsdl2java which extends
> org.apache.xmlbeans.XmlObject. To do so I try the next on my PortType's
> stub:
>
> (...)
> SOAPHeaderBlock headBlock = envelope.getHeader().addHeaderBlock(...);
> headBlock.addChild(toOM(myType))
> (...)
>
> private OMElement toOM(XmlObject param) {
> 	StAXOMBuilder builder = new
> StAXOMBuilder(OMAbstractFactory.getOMFactory(), new
> StreamWrapper(param.newXMLStreamReader()));
> 	OMElement documentElement = builder.getDocumentElement();
> 	((OMNodeEx) documentElement).setParent(null);
> 	return documentElement;
> }
>
>    Depending on the class I use when calling "toOM", I get a
> "java.lang.IllegalStateException", an "org.apache.axis2.om.OMException", or
> just works fine (as you may suppose, it works fine with the classes I don't
> need)
>
>    What am I doing wrong? Is that the correct way to convert from XmlObject
> to OMElement?
>
>    Thank you in advance,
>
>      Rubén