Handling array types by JBossWS Tools
anil.saldhana May 24, 2005 12:15 PMwscompile handles arrays in a special way. It isolates the array types even when the base type is a Java wrapper types like Integer into a different namespace and then imports them into the target namespace, as shown below.
package org.jboss.test.ws.tools.sei; import org.jboss.test.ws.jaxb.sei.Base; import java.rmi.Remote; import java.rmi.RemoteException; /** * An SEI with an array type * * @author <mailto:Anil.Saldhana@jboss.org>Anil Saldhana * @since Nov 3, 2004 */ public interface ArrayInterface extends Remote { public void customMethod(Base base, Integer[] a) throws RemoteException, SomeException; }
The wsdl that is generated is:
<?xml version="1.0" encoding="UTF-8"?> <definitions name="ArrayInterfaceService" targetNamespace="http://org.jboss.ws" xmlns:tns="http://org.jboss.ws" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns2="http://arrays/java/lang"> <types> <schema targetNamespace="http://arrays/java/lang" xmlns:tns="http://arrays/java/lang" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://org.jboss.ws"/> <complexType name="IntegerArray"> <sequence> <element name="value" type="int" nillable="true" minOccurs="0" maxOccurs="unbounded"/></sequence></complexType></schema> <schema targetNamespace="http://org.jboss.ws" xmlns:tns="http://org.jboss.ws" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://arrays/java/lang"/> <complexType name="Base"> <sequence> <element name="a" type="int"/> <element name="b" type="int"/></sequence></complexType> <complexType name="SomeException"> <sequence/></complexType> <element name="SomeException" type="tns:SomeException"/></schema></types> <message name="ArrayInterface_customMethod"> <part name="Base_1" type="tns:Base"/> <part name="arrayOfInteger_2" type="ns2:IntegerArray"/></message> <message name="ArrayInterface_customMethodResponse"/> <message name="SomeException"> <part name="SomeException" element="tns:SomeException"/></message> <portType name="ArrayInterface"> <operation name="customMethod" parameterOrder="Base_1 arrayOfInteger_2"> <input message="tns:ArrayInterface_customMethod"/> <output message="tns:ArrayInterface_customMethodResponse"/> <fault name="SomeException" message="tns:SomeException"/></operation></portType> <binding name="ArrayInterfaceBinding" type="tns:ArrayInterface"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> <operation name="customMethod"> <soap:operation soapAction=""/> <input> <soap:body use="literal" namespace="http://org.jboss.ws"/></input> <output> <soap:body use="literal" namespace="http://org.jboss.ws"/></output> <fault name="SomeException"> <soap:fault name="SomeException" use="literal"/></fault></operation></binding> <service name="ArrayInterfaceService"> <port name="ArrayInterfacePort" binding="tns:ArrayInterfaceBinding"> <soap:address location="REPLACE_WITH_ACTUAL_URL"/></port></service></definitions>
As you can see, wscompile has special array handling.
When there are custom user types and arrays of them, it is similar.
/* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.ws.tools.jbws_161.custom; /** * Remote interface for Hello. */ public interface HelloCustomRemote extends java.rmi.Remote { public String helloString(String name) throws java.rmi.RemoteException; public HelloObj helloBean(HelloObj bean) throws java.rmi.RemoteException; public HelloObj[] helloArray(HelloObj[] query) throws java.rmi.RemoteException; }
<?xml version="1.0" encoding="UTF-8"?> <definitions name="HelloCustomService" targetNamespace="http://org.jboss/types" xmlns:tns="http://org.jboss/types" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns2="http://org.jboss/types/arrays/org/jboss/test/ws/tools/jbws_161/custom" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> <types> <schema targetNamespace="http://org.jboss/types/arrays/org/jboss/test/ws/tools/jbws_161/custom" xmlns:tns="http://org.jboss/types/arrays/org/jboss/test/ws/tools/jbws_161/custom" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://org.jboss/types" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://org.jboss/types"/> <complexType name="HelloObjArray"> <sequence> <element name="value" type="ns2:HelloObj" nillable="true" minOccurs="0" maxOccurs="unbounded"/> </sequence> </complexType> </schema> <schema targetNamespace="http://org.jboss/types" xmlns:tns="http://org.jboss/types" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://org.jboss/types/arrays/org/jboss/test/ws/tools/jbws_161/custom"/> <complexType name="HelloObj"> <sequence> <element name="msg" type="string" nillable="true"/> </sequence> </complexType> </schema> </types> <message name="HelloCustomRemote_helloArray"> <part name="arrayOfHelloObj_1" type="ns2:HelloObjArray"/> </message> <message name="HelloCustomRemote_helloArrayResponse"> <part name="result" type="ns2:HelloObjArray"/> </message> <message name="HelloCustomRemote_helloBean"> <part name="HelloObj_1" type="tns:HelloObj"/> </message> <message name="HelloCustomRemote_helloBeanResponse"> <part name="result" type="tns:HelloObj"/> </message> <message name="HelloCustomRemote_helloString"> <part name="String_1" type="xsd:string"/> </message> <message name="HelloCustomRemote_helloStringResponse"> <part name="result" type="xsd:string"/> </message> <portType name="HelloCustomRemote"> <operation name="helloArray" parameterOrder="arrayOfHelloObj_1"> <input message="tns:HelloCustomRemote_helloArray"/> <output message="tns:HelloCustomRemote_helloArrayResponse"/> </operation> <operation name="helloBean" parameterOrder="HelloObj_1"> <input message="tns:HelloCustomRemote_helloBean"/> <output message="tns:HelloCustomRemote_helloBeanResponse"/> </operation> <operation name="helloString" parameterOrder="String_1"> <input message="tns:HelloCustomRemote_helloString"/> <output message="tns:HelloCustomRemote_helloStringResponse"/> </operation> </portType> <binding name="HelloCustomRemoteBinding" type="tns:HelloCustomRemote"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> <operation name="helloArray"> <soap:operation soapAction=""/> <input> <soap:body use="literal" namespace="http://org.jboss/types"/> </input> <output> <soap:body use="literal" namespace="http://org.jboss/types"/> </output> </operation> <operation name="helloBean"> <soap:operation soapAction=""/> <input> <soap:body use="literal" namespace="http://org.jboss/types"/> </input> <output> <soap:body use="literal" namespace="http://org.jboss/types"/> </output> </operation> <operation name="helloString"> <soap:operation soapAction=""/> <input> <soap:body use="literal" namespace="http://org.jboss/types"/> </input> <output> <soap:body use="literal" namespace="http://org.jboss/types"/> </output> </operation> </binding> <service name="HelloCustomService"> <port name="HelloCustomRemotePort" binding="tns:HelloCustomRemoteBinding"> <soap:address location="REPLACE_WITH_ACTUAL_URL"/> </port> </service> </definitions>
So this is a task that needs to be implemented with care and solid testcases.