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