10 Replies Latest reply on Jun 1, 2006 9:52 AM by Frédéric EECKHOUT

    emtpy argument becomes null?

    Chris Laprun Master

      One thing I've noticed is that the method I'm trying to call on my endpoint takes two parameters the second of which is a String[]. The client code I'm using passes an empty array for the second parameter. However, by the time it gets to the endpoint, the array is null. Is that an expected behavior?

        • 1. Re: emtpy argument becomes null?
          Thomas Diesler Master

          It depends on the abstract contract defined in wsdl. To investigate this, we'd need a sample deployment or a modification to one of the existing test case.

          • 3. Re: emtpy argument becomes null?
            Frédéric EECKHOUT Newbie

            1/ I'm using JBossAS 4.0.4CR2 (with JBossWS 1.0.0CR6..?), and this bug doesn't like to be fixed !
            When I have an empty array, the client get a null.

            2/ When an array has only one object, the client get the object, and not the array with one object. Is that an expected behavior ?

            • 5. Re: emtpy argument becomes null?
              Frédéric EECKHOUT Newbie

              I have already seen JBWS-732, but it do not fix the problem. (done for jboss-1.0.0.CR4 and I'm running with jboss-1.0.0.CR6).

              After migrating from old axis solution with additional war to this annoted webservice (I was happy), I must re-use Axis.

              Why does it work with Axis ?
              -> the generated wsdl is different for the arrays : (field "definitions", an array of Definition objects)

              Axis :

              <complexType name="ArrayOf_tns1_Definition">
               <complexContent>
               <restriction base="soapenc:Array">
               <attribute ref="soapenc:arrayType" wsdl:arrayType="tns1:Definition[]"/>
               </restriction>
               </complexContent>
              </complexType>
              
              ....
               <element name="definitions" nillable="true" type="impl:ArrayOf_tns1_Definition"/>
              ...


              JbossWS :
              ...
              <element maxOccurs='unbounded' minOccurs='0' name='definitions' nillable='true' type='tns:Definition'/>
              ...


              Both :
              <complexType name='Definition'>
               <sequence>
               <element name='champObjet' nillable='true' type='string'/>
               <element name='classe' nillable='true' type='string'/>
               <element name='filtrable' type='int'/>
               <element name='modifiable' type='int'/>
               <element name='nom' nillable='true' type='string'/>
               <element name='requis' type='boolean'/>
               <element name='type' nillable='true' type='string'/>
               <element name='valeurDefaut' nillable='true' type='string'/>
               </sequence>
              </complexType>



              Axis solution looks like what is recommended at this page :
              http://www-128.ibm.com/developerworks/webservices/library/ws-array.html

              "The thing to be aware of is that an array in most programming languages is really made up of two things: there are the contents of the array; and there is the array itself - a wrapper, if you like, around the contents. An XML 'array' is only a list of the elements. There is no wrapper."

              wsdl :
              <complexType name="arrayWrapper">
               <sequence>
               <element name="el" nillable="true" maxOccurs="unbounded" minOccurs="0" type="xsd:int"/>
               </sequence>
              </complexType>
              <complexType name="bean">
               <sequence>
               <element name="name" type="xsd:string"/>
               <element name="array" nillable="true" type="tns:arrayWrapper"/>
               </sequence>
              </complexType>



              Don't you think it's a better way ?


              • 6. Re: emtpy argument becomes null?
                Thomas Diesler Master

                Axis uses soap encoding (rpc/encoded), which is not allowed by the basic profile.

                 <restriction base="soapenc:Array">
                 <attribute ref="soapenc:arrayType" wsdl:arrayType="tns1:Definition[]"/>
                 </restriction>
                


                You need to use rpc/literal or document/literal with portable J2EE-1.4 WS endpoints

                • 7. Re: emtpy argument becomes null?
                  Frédéric EECKHOUT Newbie

                  I don't think that making ws response with null object instead of empty array, or simple object instead of array of one simple object is "portable J2EE-1.4 WS endpoints" ! That exactly what JBossWS do... and not Axis.
                  Strangly, I cannot use Java as ws client of my JBossWS endpoint : I've got a "Null pointer exception", when I can use both Java and PHP (I don't tried any other language..) with Axis endpoint... Which one is the most portable ?

                  And,

                  <complexType name="arrayWrapper">
                   <sequence>
                   <element name="el" nillable="true" maxOccurs="unbounded" minOccurs="0" type="xsd:int"/>
                   </sequence>
                  </complexType>
                  <complexType name="bean">
                   <sequence>
                   <element name="name" type="xsd:string"/>
                   <element name="array" nillable="true" type="tns:arrayWrapper"/>
                   </sequence>
                  </complexType>

                  is well a "rpc/literal or document/literal", why don't you use it, if it should work better ?


                  • 8. Re: emtpy argument becomes null?
                    Thomas Diesler Master

                    I do not wish to engage in an unqualified argument like this.

                    Please show me payloads that are valid in the context of the abstract contract given in wsdl + schema. Additionally, show the relevant type mapping in jaxrpc-mapping.

                    • 9. Re: emtpy argument becomes null?
                      Frédéric EECKHOUT Newbie

                      I understand the problem of mapping arrays.
                      It's just a pity this is not made better.. I'm starting to undestand that web services are made for very simple data exchange..

                      The problem is that I'm using an J2EE multi-views software structure (my development) putting all data over web.. with web services. I thought that was the better way to Interoperability.

                      • 10. Re: emtpy argument becomes null?
                        Frédéric EECKHOUT Newbie

                        Hi,

                        I see "JBossWS provides support for WS-I AP 1.0".

                        And WS-I 1.0 says :

                        http://www.ws-i.org/Profiles/BasicProfile-1.0-2004-04-16.html#refinement16556272

                        Here is the correct definition of an array :

                        <xsd:element name="MyArray1" type="tns:MyArray1Type"/>
                        
                        <xsd:complexType name="MyArray1Type">
                         <xsd:sequence>
                         <xsd:element name="x" type="xsd:string"
                         minOccurs="0" maxOccurs="unbounded"/>
                         </xsd:sequence>
                        </xsd:complexType>


                        What do you think about that ?