5 Replies Latest reply on Apr 13, 2005 8:48 AM by Thomas Diesler

    Maping a custom Array (Person[]) in java-wsdl-mapping

    Eyal Katz Newbie

      Hi All
      Here is my WebService Operation

      public Person[] getPersons();


      How should I map this Person[] in the <java-wsdl-mapping> file?

      Please provide the answer in a format like this:
      <java-type>com.hello.Person</java-type>
      <root-type-qname xmlns:ns="http://hello.com">ns:Person</root-type-qname>

      the above doesnt work btw, should I suffix Person with a '[]' ?
      How?

      Please, please answer, even if it is trivial - for us who dont know, please

      Thank you very much in advacne

      Eyal


        • 1. Re: Maping a custom Array (Person[]) in java-wsdl-mapping
          Jason Greene Master

          You need to wrap your array in an object.

          Take a look at the wiki:
          http://www.jboss.org/wiki/Wiki.jsp?page=WSArrayTypeMapping

          Thanks,
          -Jason

          • 2. Re: Maping a custom Array (Person[]) in java-wsdl-mapping
            Eyal Katz Newbie

            Hi Jason,

            First, allow me to thank you for your reply which greatly help us newcomers to JBossWS

            Second, I checked the wiki you posted and:

            1.
            why do I need ws4ee-deployment.xml ?

            2.
            this file is not J2EE 1.4 mandatory (and JBoss 4 is J2EE 1.4 compilant)

            3.
            shouldnt it be enough to supply webservices.xml with a <jaxrpc-mapping-file> tag which points to the appropriate mapping scheme?

            4.
            where do I put ws4ee-deployment.xml ? under META-INF ?
            can you provide a link where we can read about it?

            If you could answer these 4 issues, it would be great

            Again, thanks very much

            Eyal

            • 3. Re: Maping a custom Array (Person[]) in java-wsdl-mapping
              Jason Greene Master

               

              "eykatz" wrote:
              Hi Jason,
              1.
              why do I need ws4ee-deployment.xml ?


              I should update the wiki on that, you most likely won't need it. Try it without it first.


              2.
              this file is not J2EE 1.4 mandatory (and JBoss 4 is J2EE 1.4 compilant)


              Containers are free to require container specific deployment artifactss. This is used all over the place by many different containers (an example would be jndi mapping)



              3.
              shouldnt it be enough to supply webservices.xml with a <jaxrpc-mapping-file> tag which points to the appropriate mapping scheme?


              Yes, and it most cases it will work without it. The ws4ee-deployment descriptor is purely a workaround component due to a combination of factors (i.e. problems with jax-rpc 1.1 & axis (used internally in the current ws4ee implementation)). The next release of JBossWS is a complete rewrite, and will not have the problems that require this file.


              4.
              where do I put ws4ee-deployment.xml ? under META-INF ?
              can you provide a link where we can read about it?


              WEB-INF if its a JSE
              META-INF if its a web service endpoint

              -Jason


              • 4. Re: Maping a custom Array (Person[]) in java-wsdl-mapping
                Eyal Katz Newbie

                Hi Jason,

                The wiki says you need to wrap the array in some bean, so:

                public interface MySingleMethodEndpoint {
                 Person[] getPersons();
                }
                

                Should become:
                public interface MySingleMethodEndpoint {
                 PersonList getPersons();
                }
                

                where PersonList is:
                 class PersonList {
                 private Person[] list;
                 getList() / setList(...)
                 }
                


                --------------------------------

                This wont work as well...
                Before offering a solution - let's see if all is understood correctly:
                At deploy time, JBoss:
                1. Looks for webservices.xml
                2. Looks for the wsdl and <jaxrpc-mapping-file>.xml file (specified inside the webservices.xml)
                3. Looks for a ws4ee-deployment.xml (optionally), explained later
                4. Creates a .wsdd out of the above files - this file is used by Axis to deploy the web service

                After that, JBoss (actually Axis) doesnt rely on webserivces.xml and its J2EE 1.4 comlpiant friends
                It relies only on the wsdd (which is very much Okay because this is implementation specifiec)

                But, If you look at the wsdd generated from our 'PersonList' example, you will see ONLY ONE type-mapping:
                 <typeMapping
                 qname='ns2:PersonList' xmlns:ns2='http://structs.myservice.com'
                 type='java:com.myservice.structs.PersonList'
                 serializer='org.apache.axis.encoding.ser.BeanSerializerFactory'
                 deserializer='org.apache.axis.encoding.ser.BeanDeserializerFactory'
                 encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
                 </typeMapping>
                


                JBoss should've automatically generated a type-mapping descriptor for class 'Person' as well
                To solve this probelm, add the 'Person' mapping yourself to ws4ee-deployment.xml
                When you supply this optionaly file, JBoss merges its content with the generated .wsdd (At Step #3 of the above scenario)
                The 'Person' mapping should look like this:
                 <typeMapping
                 qname='ns2:Person' xmlns:ns2='http://structs.myservice.com'
                 type='java:com.myservice.structs.Person'
                 serializer='org.apache.axis.encoding.ser.BeanSerializerFactory'
                 deserializer='org.apache.axis.encoding.ser.BeanDeserializerFactory'
                 encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
                 </typeMapping>
                


                This will solve the PersonList problem


                -----------------------------------------------------------------------------------

                In fact, you can even return to the first version of your web service:
                public interface MySingleMethodEndpoint {
                Person[] getPersons();
                }

                once, you have the ws4ee-deployment.xml descriptor, you can use plain arrays in your web services

                -----------------------------------------------------------------------------------

                Jason, could it be that I missed something in the other DD files (.wsdl, jaxrpc-mapping, jboss.xml) which prevented
                'Person' from being auto-generated and inserted into the .wsdd file?

                Again, Thanks a lot for your time...

                Eyal

                • 5. Re: Maping a custom Array (Person[]) in java-wsdl-mapping
                  Thomas Diesler Master

                  The Step by Step Tutorials recommend that you generate the wrapping java bean and the associated jaxrpc-mapping.xml, why does this not work for you?