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 Rod Biresch <rb...@chariotsolutions.com> on 2011/03/09 17:36:14 UTC

Need xmlns="" namespace in xml element for Axis2 client payload

I'm upgrade an old Axis1 client to Axis 2 ver. 1.5.4.  I was able to
refactor the code just fine and ran some tests against the web service.  It
turns out that I have a problem with one xml element.  The element is
missing xmlns="", which is causing a validation error on the server.  If I
simply modify the payload and add only that xmlns="" attribute to the Order
xml element (i.e. <Order xmlns="">) the payload validates and the web
service works fine.

I assume the WSDL controls how the code is generated to render this element.
 A part of the WSDL...

<s:schema elementFormDefault="qualified" targetNamespace="http://blah/blah">
...
    <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Order">
...

So, the question is how can I have Axis2 send the <Order xmlns=""> instead
of <Order> ?

Oh, I generated the code using the following command:

$ wsdl2java.sh -uri sample.wsdl -p <package name> -d adb -s

btw...the Axis1 client works fine and produces <Order xmlns=""> in the
payload.

Thanks in advance,
Rod

RE: Need xmlns="" namespace in xml element for Axis2 client payload

Posted by Martin Gainty <mg...@hotmail.com>.
If in your schema you use elementFormDefault="qualified" then you will validate all of the documents above 
if in your schema you use elementFormDefault="unqualified" then you will not namespace qualify your document e.g.
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:po="http://www.example.com/PO1"
        targetNamespace="http://www.example.com/PO1"
        elementFormDefault="unqualified"
        attributeFormDefault="unqualified">
  <element name="purchaseOrder" type="po:PurchaseOrderType"/>
  <element name="comment"       type="string"/>
  <complexType name="PurchaseOrderType">
    <sequence>
      <element name="shipTo"    type="po:USAddress"/>
      <element name="billTo"    type="po:USAddress"/>
      <element ref="po:comment" minOccurs="0"/>
      <!-- etc. -->
    </sequence>
    <!-- etc. -->
  </complexType>
  <complexType name="USAddress">
    <sequence>
      <element name="name"   type="string"/>
      <element name="street" type="string"/>
      <!-- etc. -->
    </sequence>
  </complexType>
  <!-- etc. -->
</schema>
http://www.w3.org/TR/xmlschema-0/

HTH
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




Date: Fri, 11 Mar 2011 17:48:17 -0500
Subject: Re: Need xmlns="" namespace in xml element for Axis2 client payload
From: rbiresch@chariotsolutions.com
To: java-user@axis.apache.org

I've gotten past my schema validation error by using the XMLBeans data binding.  XMLBeans data binding option did NOT insert the xmlns="" attribute however, it did generate XML that passed the web service validation.

Thanks,
Rod

On Wed, Mar 9, 2011 at 11:36 AM, Rod Biresch <rb...@chariotsolutions.com> wrote:

I'm upgrade an old Axis1 client to Axis 2 ver. 1.5.4.  I was able to refactor the code just fine and ran some tests against the web service.  It turns out that I have a problem with one xml element.  The element is missing xmlns="", which is causing a validation error on the server.  If I simply modify the payload and add only that xmlns="" attribute to the Order xml element (i.e. <Order xmlns="">) the payload validates and the web service works fine.


I assume the WSDL controls how the code is generated to render this element.  A part of the WSDL...
<s:schema elementFormDefault="qualified" targetNamespace="http://blah/blah">

...    <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Order">...
So, the question is how can I have Axis2 send the <Order xmlns=""> instead of <Order> ?


Oh, I generated the code using the following command:
$ wsdl2java.sh -uri sample.wsdl -p <package name> -d adb -s
btw...the Axis1 client works fine and produces <Order xmlns=""> in the payload.


Thanks in advance,Rod

 		 	   		  

Re: Need xmlns="" namespace in xml element for Axis2 client payload

Posted by Rod Biresch <rb...@chariotsolutions.com>.
I've gotten past my schema validation error by using the XMLBeans data
binding.  XMLBeans data binding option did NOT insert the xmlns="" attribute
however, it did generate XML that passed the web service validation.

Thanks,
Rod

On Wed, Mar 9, 2011 at 11:36 AM, Rod Biresch
<rb...@chariotsolutions.com>wrote:

> I'm upgrade an old Axis1 client to Axis 2 ver. 1.5.4.  I was able to
> refactor the code just fine and ran some tests against the web service.  It
> turns out that I have a problem with one xml element.  The element is
> missing xmlns="", which is causing a validation error on the server.  If I
> simply modify the payload and add only that xmlns="" attribute to the Order
> xml element (i.e. <Order xmlns="">) the payload validates and the web
> service works fine.
>
> I assume the WSDL controls how the code is generated to render this
> element.  A part of the WSDL...
>
> <s:schema elementFormDefault="qualified" targetNamespace="http://blah/blah
> ">
> ...
>     <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Order">
> ...
>
> So, the question is how can I have Axis2 send the <Order xmlns=""> instead
> of <Order> ?
>
> Oh, I generated the code using the following command:
>
> $ wsdl2java.sh -uri sample.wsdl -p <package name> -d adb -s
>
> btw...the Axis1 client works fine and produces <Order xmlns=""> in the
> payload.
>
> Thanks in advance,
> Rod
>