6 Replies Latest reply on Jul 23, 2005 5:24 AM by Thomas Diesler

    Deserialized array is of size 1!!

    Anirban Basu Newbie

      I am using JBoss 4.0.2 on JRE 1.5, Eclipse 3.0.2 with JBoss IDE 1.4.1-e31-jre15. I have a session bean, which has two methods exposed to a service endpoint interface. I have written my jaxrpc-mapping.xml, webservices.xml and ws4ee-deployment.xml (to map custom data types to appropriate deserializers). One of these methods is supposed to return an array of custom beans. I wrapped the array as a bean, which is something like:

      public class MyArrayWrapper {
       private MyDataType[] underlyingArray;
       private String anotherField;
       //public no argument constructor
       //public getter/setters
      }
      


      I have additional methods inside the array (not getter/setters) which can be used by the session bean to resize the array dynamically and set the data at a particular index in the array, but I don't think that matters to the serializer. I use
      org.jboss.webservice.encoding.ser.MetaDataBeanSerializerFactory
      and
      org.jboss.webservice.encoding.ser.MetaDataBeanDeSerializerFactory
      to handle this array as well as the the MyDataType, which is a simple Java bean.

      I use Java2WSDL to generate the WSDL, which looks like the following in its type mapping for the array.
      <schema targetNamespace="http://myservice.session.mycompany.com" xmlns="http://www.w3.org/2001/XMLSchema">
       <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
       <complexType name="ArrayOf_tns3_MyDataType">
       <complexContent>
       <restriction base="soapenc:Array">
       <attribute ref="soapenc:arrayType" wsdl:arrayType="tns3:MyDataType[]"/>
       </restriction>
       </complexContent>
       </complexType>
       </schema>
       <schema targetNamespace="http://myservice.session.mycompany.com" xmlns="http://www.w3.org/2001/XMLSchema">
       <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
       <complexType name="MyArrayWrapper">
       <sequence>
       <element name="underlyingArray" nillable="true" type="impl:ArrayOf_tns3_MyDataType"/>
       <element name="anotherField" type="xsd:string"/>
       </sequence>
       </complexType>
       </schema>
      


      Using rpc/LITERAL, the service deploys fine apart from a jaxrpc-warning about type mapping, which I do not understand because the package it complains about exists and is mapped in jaxrpc-mapping.xml. Anyway, that's a warning.

      I use an Axis client (JRE 1.5 generated by JBoss IDE) to invoke the WS call. The call succeeds without any error on the server. I have Axis servlet logging turned on. The response SOAP message looks perfect with all the necessary data. The response array contains 28 elements (say) but the client only gets one element after deserializing the SOAP message. What's going wrong? Why is the array getting trimmed to one element?

        • 1. Re: Deserialized array is of size 1!!
          Anirban Basu Newbie

          Since no one has replied to my post yet, I chose to simplify the issue more. I am just trying to transport a custom bean having arrays of two different types. One of them is a string array. My webservice is an EJB with a test method to return an object of this custom bean and set its string array to contain four strings "Hello", "World", "from" and "Web service" The SOAP message sent to the client is as follows (from server log)

          <?xml version="1.0" encoding="UTF-8"?>
          <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
           <soapenv:Body>
           <ns1:testWSArrayResponseResponse xmlns:ns1="http://mydatatype.mycompany.com">
           <testWSArrayResponseResponse>
           <customerArray xsi:nil="1"/>
           <stringArray>Hello</stringArray>
           <stringArray>World</stringArray>
           <stringArray>from</stringArray>
           <stringArray>Web service</stringArray>
           <timeStamp>2005-07-21T23:47:16.224Z</timeStamp>
           </testWSArrayResponseResponse>
           </ns1:testWSArrayResponseResponse>
           </soapenv:Body>
          </soapenv:Envelope>
          
          

          In the client, I just get one element in this array which contains a value "Web service". How did the other four elements disappear? By the way, I am using JDK 1.4 for both the server and the client if 1.5 is to be blamed without any question. There is no error or even warning in the server log (set to DEBUG level) and still the client cannot get it right. What's this all about?

          • 2. Re: Deserialized array is of size 1!!
            Anil Saldanha Master

            You are using rpc/encoded web services. JBoss Web Services supports only doc/lit and rpc/lit. We recommend using wscompile (Sun's JWSDP) as the web services tool and not axis's java2wsdl or wsdl2java.

            • 3. Re: Deserialized array is of size 1!!
              Anirban Basu Newbie

              The WSDL and the WSDD (generated by JBoss at runtime) clearly mentions that I am using rpc/literal. On another instance, I did try to switch to rpc/encoded but it did not work. Since then, I am using rpc/literal.

              • 4. Re: Deserialized array is of size 1!!
                Thomas Diesler Master

                Does it? Here I see SOAP encoding.

                 <complexType name="ArrayOf_tns3_MyDataType">
                 <complexContent>
                 <restriction base="soapenc:Array">
                 <attribute ref="soapenc:arrayType" wsdl:arrayType="tns3:MyDataType[]"/>
                 </restriction>
                 </complexContent>
                


                We recommend using wscompile over java2wsdl, because the Axis tools do not generate WS4EE compliant artifacts

                • 5. Re: Deserialized array is of size 1!!
                  Anirban Basu Newbie

                  Using wscompile now. Works perfect. Thanks.

                  However, I note that JBoss only supports document/literal or rpc/literal. wscompile does not support Collections (like java.util.Vector) on literal. Any way around this?

                  Although I am debating about the choice of simple arrays over java.util.Vector. May be a Java 1.5 typed java.util.Vector will be more sensible in the context of web services when such implementations are done but as of now, arrays look more promising - simple and straightforward and may be easy to interoperate with non-Java tools.

                  By the way, what is JBoss' intentions/support/plans for grid services?

                  • 6. Re: Deserialized array is of size 1!!
                    Thomas Diesler Master

                    Collections are not supported because not every soap stack has a notion of collections. The spec would tell you exactly what types are supported.

                    You could checkout the roadmap.