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 10569] New: - Prevent xsi:type from being generated for ElementSerializer
Date Mon, 08 Jul 2002 22:00: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=10569>.
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=10569

Prevent xsi:type from being generated for ElementSerializer

           Summary: Prevent xsi:type from being generated for
                    ElementSerializer
           Product: Axis
           Version: beta-2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Serialization/Deserialization
        AssignedTo: scheu@us.ibm.com
        ReportedBy: scheu@us.ibm.com
                CC: axis-dev@xml.apache.org


Note from Dirk Wollscheid.

I'm still not entirely happy with the fix for 9927. The ElementSerializer still 
adds the xsi:type even though I call the RPCParam.setXSITypeGeneration(false)

Here's my example code

	public static void main(String[] args) {
		MessageContext msgContext = new MessageContext(new 
AxisServer());

		String req =
			"<xsd1:A xmlns:xsd1='urn:myNamespace'>"
				+ "<B>"
				+ "<C>foo bar</C>"
				+ "</B>"
				+ "</xsd1:A>";

		try {			
			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("urn:myNamespace", 
"testParam", document.getFirstChild());
			arg1.setXSITypeGeneration(false);

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

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

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

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

and here's the output:

<?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:myNamespace">
   <ns1:testParam xsi:type="ns2:Element" 
xmlns:ns2="http://xml.apache.org/xml-soap">
    <xsd1:A xmlns:xsd1="urn:myNamespace">
     <B>
      <C>foo bar</C>
     </B>
    </xsd1:A>
   </ns1:testParam>
  </ns1:method1>
 </soapenv:Body>
</soapenv:Envelope>

My problem is that a user's WSDL might have a type for the testParam Element 
(let's say TestParamType). Now when the axis elementserializer serizlizes my 
parameter (that I explictly say not to generate an xsi:type for), it declares 
the type as http://xml.apache.org/xml-soap:Element which would be inconsistent 
with the WSDL.

So in my opinion the ElementSerializer (and probably some other serializers) 
have to be changed to use the  set/getXSITypeGeneration methods

What do you think?

Mime
View raw message