XMLBeans - xsi:type stripped using Axis2 and Tomcat?
Posted
by Matthew Gamble
on Stack Overflow
See other posts from Stack Overflow
or by Matthew Gamble
Published on 2010-02-24T18:57:55Z
Indexed on
2010/04/20
13:03 UTC
Read the original article
Hit count: 469
I’m new to XMLBeans and have been trying to use it to create an XML document as part of an axis2 web service. When I run my code as a standard Java application or as a standard servlet, the XML is correctly generated:
<?xml version="1.0" encoding="UTF-8"?>
<c:BroadsoftDocument protocol="OCI" xmlns:c="C">
<sessionId>000000001</sessionId>
<command xsi:type="AuthenticationRequest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<userId>admin</userId></command>
</c:BroadsoftDocument>
However, when the exact same code is run under Axis2 & Tomcat in a servlet I get:
<?xml version="1.0" encoding="UTF-8"?>
<c:BroadsoftDocument protocol="OCI" xmlns:c="C">
<sessionId>000000001</sessionId>
<command>
<userId>admin</userId></command>
</c:BroadsoftDocument>
This of course isn’t valid – the xsi:type of the “command” element is stripped when the code is run under Tomcat.
Does anyone have any suggestions of what I could be doing wrong that would cause this type of issue only when running under Axis2? At first I thought it was a Tomcat issue, but after creating a generic servlet and running the exact same code I don't have any issues. I've tried playing with the XMLOptions for XMLBeans, but couldn't seem to resolve the problem. The options I'm currently using are:
xmlOptions = new XmlOptions();
xmlOptions.setCharacterEncoding("UTF-8");
xmlOptions.setUseDefaultNamespace();
xmlOptions.setSaveAggressiveNamespaces();
xmlOptions.setSavePrettyPrint();
© Stack Overflow or respective owner