Version 3

    Deprecated - Mapping arrays to complex schema types

     

    The following example is taken from JBWS-423

     

     

     

     

    XMLSchema has no special type identifier for arrays, instead it uses maxOccurs with a value greater than 1.

     

      <types>
        <schema targetNamespace="http://org.jboss.test.webservice/jbws423/types/arrays/org/jboss/test/webservice/jbws423" ...>
          <import namespace="http://org.jboss.test.webservice/jbws423/types"></import>
          <complexType name="ValueObjArray">
            <sequence>
              <element name="value" type="ns2:ValueObj" nillable="true" minOccurs="0" maxOccurs="unbounded"></element>
            </sequence>
          </complexType>
        </schema>
        <schema targetNamespace="http://org.jboss.test.webservice/jbws423/types" ...>
          <import namespace="http://org.jboss.test.webservice/jbws423/types/arrays/org/jboss/test/webservice/jbws423"></import>
          <complexType name="ValueObj">
            <sequence>
              <element name="s1" type="string" nillable="true"></element>
              <element name="s2" type="string" nillable="true"></element>
            </sequence>
          </complexType>
        </schema>
      </types>
    

     

    Here is an example of an SEI using an array as return value.

     

       public interface DemoEndpoint extends Remote
       {
          public ValueObj[] getArray() throws RemoteException;
    
          public ValueObj[] getEmptyArray() throws RemoteException;
    
          public ValueObj[] getNullArray() throws RemoteException;
       }
    

     

    Unfortunately, wscompile does not generate the required type mapping in jaxrpc-mapping.xml. This needs to be added manually like this.

     

      <!-- Add these type mappings -->
      <java-xml-type-mapping>
        <java-type>org.jboss.test.webservice.jbws423._arrays.org.jboss.test.webservice.jbws423.ValueObjArray</java-type>
        <root-type-qname xmlns:typeNS="http://org.jboss.test.webservice/jbws423/types/arrays/org/jboss/test/webservice/jbws423">typeNS:ValueObjArray</root-type-qname>
        <qname-scope>complexType</qname-scope>
      </java-xml-type-mapping>
      <java-xml-type-mapping>
        <java-type>org.jboss.test.webservice.jbws423.ValueObj</java-type>
        <root-type-qname xmlns:typeNS="http://org.jboss.test.webservice/jbws423/types">typeNS:ValueObj</root-type-qname>
        <qname-scope>complexType</qname-scope>
      </java-xml-type-mapping>
    

     

    The wrapper bean is also generated by wscompile with the -keep option and must be included in your deployment.

     

     

     

     

    Note, that org.apache.axis.encoding.ser.ArraySerializer is for the use of soap style array encoding (rpc/encoded) and should not be used with literal encoding.

     

    Easier Solution

     

    I(Ormek) solved this in a different way. Adding simply an array description as the type for the element did work, without any wrapper classes.

     

    <java-xml-type-mapping>
        <java-type>org.jboss.test.webservice.jbws423.ValueObj[]</java-type>
        <root-type-qname xmlns:impl="http://org.jboss.test.webservice/jbws423/types">impl:ValueObjArray</root-type-qname>
        <qname-scope>element</qname-scope>
    </java-xml-type-mapping>