axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 10605] New: - serializers add unnecessary default namespace decl for literal enc
Date Tue, 09 Jul 2002 18:45:49 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10605>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10605

serializers add unnecessary default namespace decl for literal enc

           Summary: serializers add unnecessary default namespace decl for
                    literal enc
           Product: Axis
           Version: current (nightly)
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Serialization/Deserialization
        AssignedTo: axis-dev@xml.apache.org
        ReportedBy: wollsch@us.ibm.com


This is with the 07/09 nightly build.

My test case creates a SOAP envelope like this :

SOAPEnvelope msg = new SOAPEnvelope();			
RPCParam arg1 = new RPCParam("testParam", document.getFirstChild());
arg1.setXSITypeGeneration(false);
			
RPCElement body = new RPCElement("urn:myNamespace2", "method1", new Object[] { arg1 });
msg.addBodyElement(body);
body.setEncodingStyle(Constants.URI_LITERAL_ENC);

Note that the testParam isn't in any namespace!

Now the serialized envelope looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <method1 xmlns="urn:myNamespace2">
   <testParam>
    <xsd1:A xmlns:xsd1="urn:myNamespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <B>
      <C>foo bar</C>
     </B>
    </xsd1:A>
   </testParam>
  </method1>
 </soapenv:Body>
</soapenv:Envelope>

Note that now the "testparam" is in the "urn:myNameSpace2" because the serializer added a
default namespace.

This is not a big deal, but something that should be fixed. 

For SOAP encoding it works: 

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <ns1:method1 soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:myNamespace2">
   <testParam>
    <xsd1:A xmlns:xsd1="urn:myNamespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <B>
      <C>foo bar</C>
     </B>
    </xsd1:A>
   </testParam>
  </ns1:method1>
 </soapenv:Body>
</soapenv:Envelope>

Here's my code:

		String req =				
				"<xsd1:A xmlns:xsd1='urn:myNamespace' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>"+
				"<B>"+
				"<C>foo bar</C>"+
				"</B>"+
				"</xsd1:A>";


			StringWriter stringWriter=new StringWriter();
			StringReader reqReader = new StringReader(req);			
			InputSource reqSource = new InputSource(reqReader);
			
			DocumentBuilder xdb = DocumentBuilderFactory.newInstance().newDocumentBuilder();
			Document document = xdb.parse(reqSource );

			String msgString = null;

			SOAPEnvelope msg = new SOAPEnvelope();			
			RPCParam arg1 = new RPCParam("testParam", document.getFirstChild());
			arg1.setXSITypeGeneration(false);
			

			RPCElement body = new RPCElement("urn:myNamespace2", "method1", new Object[] { arg1 });
			msg.addBodyElement(body);
			body.setEncodingStyle(Constants.URI_LITERAL_ENC);

			SerializationContext context = new SerializationContextImpl(stringWriter, msgContext);
			msg.output(context);

			msgString = stringWriter.toString();
			System.out.println(msgString);

Mime
View raw message