5 Replies Latest reply on Apr 12, 2005 12:49 PM by thomas.diesler

    wscompile handling SEI with custom types

    anil.saldhana

      I want to know if any of you know why wscompile splits the schema into two when dealing with a Service Endpoint Interface that contains a custom user type and an array of custom user types.

      SEI:

      /*
       * 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;
      
      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;
      
      }


      HelloObj is a custom java bean.

      wscompile generates the following wsdl
      <?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>


      As you can see that the types is split into two schemas, one for the array of custom type and one for the custom type itself and each schema imports the namespace of the other.

      I am wondering as to why wscompile does the schema in such a complex way, for this particular case.

        • 1. Re: wscompile handling SEI with custom types
          anil.saldhana

           

          <types>
           </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">
           <complexType name="HelloObj">
           <sequence>
           <element name="msg" type="string" nillable="true"/>
           </sequence>
           </complexType>
          
           <complexType name="HelloObjArray">
           <sequence>
           <element name="value" type="tns:HelloObj" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
           </sequence>
           </complexType>
           </schema>
           </types>
          


          Why isn't the above valid schema in types?

          • 2. Re: wscompile handling SEI with custom types
            jason.greene

            Is HelloObj in a different package, it looks like it does a namespace per java package?

            • 3. Re: wscompile handling SEI with custom types
              anil.saldhana

              They are in the same package as shown

              package org.jboss.test.ws.tools.jbws_161.custom;
              
              
              /** A custom data object class that needs to specify a custom serializer
               */
              public class HelloObj implements java.io.Serializable
              {
               private String msg;
              
               public HelloObj()
               {
               this(null);
               }
              
               public HelloObj(String msg)
               {
               this.msg = msg;
               }
              
               public String getMsg()
               {
               return this.msg;
               }
              
               public void setMsg(String msg)
               {
               this.msg = msg;
               }
              }
              


              the config.xml is
              <configuration
               xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
              
               <service name="HelloCustomService"
               targetNamespace="http://org.jboss/types"
               typeNamespace="http://org.jboss/types"
               packageName="org.jboss.test.ws.tools.jbws_161.custom">
               <interface name="org.jboss.test.ws.tools.jbws_161.custom.HelloCustomRemote"/>
               </service>
              
              </configuration>
              


              Maybe its the case where the typenamespace and packagename dont match.

              • 4. Re: wscompile handling SEI with custom types
                jason.greene

                Actually I take that back they are introducting a new namespace that is based off of your type namespace. Perhaps they are trying to avoid a type collision between a type called FooArray and Foo[].

                http://org.jboss/types/arrays/org/jboss/test/ws/tools/jbws_161/custom

                • 5. Re: wscompile handling SEI with custom types
                  thomas.diesler

                  This raises an interesting question, namely:

                  What is the default mapping of package name to namespace?

                  The jaxrpc-2.0 spec says about this:


                  3.2 Package

                  1. The package name is tokenized using the ?.? character as a delimiter.

                  2. The order of the tokens is reversed.

                  3. If the number of tokens is zero then two tokens: ?example? and ?com? are added.

                  4. The value of the targetNamespace attribute is obtained by concatenating ?http://?, the list of tokens separated by ?.? and ?/jaxrpc?.


                  We need to address the issue of having various user types in different packages, dealing with arrays of them, mapping arrays of standard jdk types to packages. Any else?

                  As far as I know, wscompile only allows for mapping of a single package name. This is not sufficient in my humble opinion.

                  We should look at annotations for WS and how the namespaces are mapped to packages using this method. jbossws should be able to deal with multiple packages/namespaces. Sensible defaults should be available, as well as the means to set the mapping explicitly.

                  Ultimately this will be done via annotations.

                  Since a schema can only have a single targetNamespace, the usage of multiple schemas is sensible. For the particular case you are showing however, I don't see a compelling reason to do so.