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 Matthew Gamble <mg...@primustel.ca> on 2010/02/25 20:49:01 UTC

Axis2 & XMLBeans results in xsi:type getting stripped

I'm not 100% sure if this is the correct mailing list, but when I attempted
to subscribe to the axis-users list I got an error reply that it was moved
to this list so hopefully I'm posted to the correct place.

After doing some extensive testing, I've found a very strange issue when
using XMLBeans inside an axis2 web service.  I tried asking on the xmlbeans
mailing list, and they suggested I ask the question on the axis2 list as
someone might have some better insight.

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();

I've been trying everything I can think of for days trying to solve this, so
any thoughts or insights would be greatly appreciated.

--------------------------------------------------------------------------
 This electronic message contains information from Primus Telecommunications Canada Inc. ("PRIMUS") , which may be legally privileged and confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or e-mail (to the number or address above) immediately. Any views, opinions or advice expressed in this electronic message are not necessarily the views, opinions or advice of PRIMUS. It is the responsibility of the recipient to ensure that any attachments are virus free and PRIMUS bears no responsibility for any loss or damage arising in any way from the use thereof.The term "PRIMUS" includes its affiliates.
--------------------------------------------------------------------------
 Pour la version en français de ce message, veuillez voir
http://www.primustel.ca/fr/legal/cs.htm
This message (and any associated files) is intended only for the 
use of the individual or entity to which it is addressed and may 
contain information that is confidential, subject to copyright or
constitutes a trade secret. If you are not the intended recipient 
you are hereby notified that any dissemination, copying or 
distribution of this message, or files associated with this message, 
is strictly prohibited. If you have received this message in error, 
please notify us immediately by replying to the message and deleting 
it from your computer. Messages sent to and from us may be monitored. 

Internet communications cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, arrive 
late or incomplete, or contain viruses. Therefore, we do not accept 
responsibility for any errors or omissions that are present in this 
message, or any attachment, that have arisen as a result of e-mail 
transmission. If verification is required, please request a hard-copy 
version. Any views or opinions presented are solely those of the author 
and do not necessarily represent those of the company.

Re: Axis2 & XMLBeans results in xsi:type getting stripped

Posted by Amila Suriarachchi <am...@gmail.com>.
have you generated code with wsdl2java tool?
Can you send us a sample wsdl and client/server to show the problem?

thanks,
Amila.

On Fri, Feb 26, 2010 at 1:19 AM, Matthew Gamble <mg...@primustel.ca>wrote:

>  I'm not 100% sure if this is the correct mailing list, but when I
> attempted to subscribe to the axis-users list I got an error reply that it
> was moved to this list so hopefully I'm posted to the correct place.
>
> After doing some extensive testing, I've found a very strange issue when
> using XMLBeans inside an axis2 web service.  I tried asking on the xmlbeans
> mailing list, and they suggested I ask the question on the axis2 list as
> someone might have some better insight.
>
> 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"<http://www.w3.org/2001/XMLSchema-instance%22>
> >
>     <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();
>
> I've been trying everything I can think of for days trying to solve this,
> so any thoughts or insights would be greatly appreciated.
>  ------------------------------
>  This electronic message contains information from PrimusTelecommunications Canada Inc. ("
> PRIMUS") , which may be legally privileged and confidential. The
> information is intended to be for the use of the individual(s) or entity
> named above. If you are not the intended recipient, be aware that any
> disclosure, copying, distribution or use of the contents of this information
> is prohibited. If you have received this electronic message in error, please
> notify us by telephone or e-mail (to the number or address above)
> immediately. Any views, opinions or advice expressed in this electronic
> message are not necessarily the views, opinions or advice of PRIMUS. It is
> the responsibility of the recipient to ensure that any attachments are virus
> free and PRIMUS bears no responsibility for any loss or damage arising in
> any way from the use thereof.The term "PRIMUS" includes its affiliates.
>  ------------------------------
>   Pour la version en français de ce message, veuillez voir
> http://www.primustel.ca/fr/legal/cs.htm
> This message (and any associated files) is intended only for the
> use of the individual or entity to which it is addressed and may
> contain information that is confidential, subject to copyright or
> constitutes a trade secret. If you are not the intended recipient
> you are hereby notified that any dissemination, copying or
> distribution of this message, or files associated with this message,
> is strictly prohibited. If you have received this message in error,
> please notify us immediately by replying to the message and deleting
> it from your computer. Messages sent to and from us may be monitored.
>
> Internet communications cannot be guaranteed to be secure or error-free
> as information could be intercepted, corrupted, lost, destroyed, arrive
> late or incomplete, or contain viruses. Therefore, we do not accept
> responsibility for any errors or omissions that are present in this
> message, or any attachment, that have arisen as a result of e-mail
> transmission. If verification is required, please request a hard-copy
> version. Any views or opinions presented are solely those of the author
> and do not necessarily represent those of the company.
>



-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/