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 Jhan Yuler <jy...@hotmail.com> on 2005/07/26 22:22:02 UTC

Serialization Response Bug???

I'm using Xmlbeans 2.0 and Axis 1.2.1 for to expose a web service usign an 
specific xml schema.

I use a java method and I expose it as a message style web service using 
Axis

This is the definition of the java method

public Document getBalanceByAccount( Document doc )

A typicaly response of this web service is like this

<soapenv:Body>
    <s1:BalInqOut xmlns:s1="http://www.hello.com32">
        <s1:Status>
            <s1:StatusCode>0</s1:StatusCode>
        </s1:Status>
    </s1:BalInqOut>
</soapenv:Body>


I want that the xml response don't use prefix in every tag. I want just use 
the default namespace like this
<soapenv:Body>
    <BalInqOut xmlns="http://www.hello.com33">
        <Status>
            <StatusCode>0</StatusCode>
        </Status>
    </BalInqOut>
</soapenv:Body>


But, when I write the code using the default namespace, the Axis core, 
rewrite all tags in the xml response and writes in every one the default 
namespace like this:

<BalInqOut xmlns="http://www.hello.com34">
    <Status xmlns="http://www.hello.com35">
        <StatusCode xmlns="http://www.hello.com36">0</StatusCode>
    </Status>
</BalInqOut>


This is the code of my java method:

   public Document getBalanceByAccount( Document res ) {
       try {
           // Here I read perfectly the request for proccess it
           //...


           // This code prepare a response to the client. This code use 
XmlBeans
           // and it is a result of the code generated from a schema 
compilation
           // using Xmlbeans.
           BalInqOutDocument out = BalInqOutDocument.Factory.newInstance();
           out.addNewBalInqOut().addNewStatus().setStatusCode(0);

           // XmlOptions are from XmlBeans and the purpose of this options 
is
           // the use of default namespace (without prefixes in every tag)
           XmlOptions opt = new XmlOptions();
           opt.setUseDefaultNamespace();

           // Here, I obtain de org.w3c.dom.Document for the response to the 
client
           // usign the options created above.
           Document docRs = (Document) out.newDomNode( opt );

           // This code prit the xml from de the docRs variable to the 
stdout and
           // this print the xml that I want.
           TransformerFactory.newInstance().newTransformer().transform(new 
DOMSource(
                   docRs), new StreamResult(System.out));

           // But, when I return this Document, the Axis core, rewrite the 
xml
           // puting the xmlns attribute in every Tag.
           return docRs;
       } catch (Throwable e) {
           e.printStackTrace(System.out);
       }
       return null;
   }

The question are:
1) Is this a bug?
2) What Can I do for obtain the result that I want???

Thanks to any one that can help me.

PD: Sorry for my english, I don't speak it perfectly