Hi Paul,
What do you mean by leading space?
There is no leading space.
The default namespace in the original DOM Element is defined as *xmlns="**
http://cis.com"*
But the OMElement returned after calling Axis2Util.toOM(Element) has no
namespace,
after adding the OMElement to the SOAPBody, every tag is included with *
xmlns=""*.
I believe somehow Axis2Util.toOM(Element) ignored the namespaces.
Regards,
Xinjun
On 1/10/07, Paul Fremantle <[EMAIL PROTECTED]> wrote:
Xinjun
Does the namespace really have a leading space as in your email? Maybe
there is a bug in how that is parsed by StAX?
Paul
On 1/10/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:
> I believe conversion between DOM Element and OMElement is quite general.
> Could anyone suggest a good way to do the conversions correctly?
>
>
>
> On 1/10/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > I am trying to convert a DOM Element to OMElement using the following
toOM
> code in org.apache.axis2.security.util.Axis2Util.
> >
> > public static OMElement toOM(Element element) throws Exception {
> > try {
> > org.apache.xml.security.Init.init();
> > ByteArrayOutputStream os = new ByteArrayOutputStream();
> > XMLUtils.outputDOM (element, os, true);
> >
> > ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray
());
> > XMLStreamReader reader =
> XMLInputFactory.newInstance().createXMLStreamReader(is);
> >
> > StAXOMBuilder builder = new StAXOMBuilder(reader);
> > builder.setCache(true);
> > return builder.getDocumentElement();
> > } catch (XMLStreamException e) {
> > log.fatal(e.getMessage(), e);
> > throw new Exception("Error when converting from DOM Element to
OM.");
> > }
> >
> > There are two problems with the code:
> > 1. I must add the bolded line in the toOM() method.
> > 2. This method seems not deal with namespace correctly.
> >
> > My original DOM Element is as follows:
> > <?xml version="1.0"
> encoding="UTF-8"?><getHearingDetailsByCaseNoWSReturn
> xmlns="
> http://cis.com
"><hearingDetailsVO><duration/><applicationNo>sAppNo0</applicationNo></hearingDetailsVO></getHearingDetailsByCaseNoWSReturn
> >
> >
> > But when I use the method to convert the DOM Element into OMElement,
it
> reads:
> >
> <getHearingDetailsByCaseNoWSReturn><hearingDetailsVO><duration
>
/><applicationNo>sAppNo0</applicationNo></hearingDetailsVO></getHearingDetailsByCaseNoWSReturn>
>
> >
> > It seems that the namespace is ignored by the Axis2Util.toOM().
> >
> > After I add the OMElement to a SOAPEnvelope using the following code,
> every element is qualified with "" namespace which is unexpected.
> >
> > SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
> > SOAPEnvelope envelope = fac.getDefaultEnvelope();
> > OMElement om = Axis2Util.toOM((Element)retNode);
> > envelope.getBody().addChild(om);
> >
> > /*******************************
> > Result SOAPEnvelope
> > *******************************/
> > <?xml version='1.0' encoding='utf-8'?>
> > <soapenv:Envelope
> > xmlns:soapenv="
> http://schemas.xmlsoap.org/soap/envelope/">
> > <soapenv:Header />
> > <soapenv:Body>
> > <getHearingDetailsByCaseNoWSReturn xmlns="">
> > <hearingDetailsVO xmlns="">
> > <duration xmlns="" />
> > <applicationNo xmlns="">sAppNo0</applicationNo>
> > </hearingDetailsVO>
> > </getHearingDetailsByCaseNoWSReturn>
> > </soapenv:Body>
> > </soapenv:Envelope>
> >
> >
> > Could anyone tell me how can I solve the problems?
> >
> >
> > Regards,
> > Xinjun
>
>
--
Paul Fremantle
VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
http://bloglines.com/blog/paulfremantle
[EMAIL PROTECTED]
"Oxygenating the Web Service Platform", www.wso2.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]