2 Replies Latest reply on Jul 22, 2005 1:47 PM by thomas.diesler

    Array wrapping a MUST when using rpc/lit ?

    fpitschi

      I want to use rpc/lit with Arrays. I have a method returning a String[].
      If I don't use a wrapper for the String[], it looks like my String[] is returned rpc/ENCODED (and not rpc/LITERAL, according to wsdl) from the server:

      <soapenv:Body>
       <ns1:hellostringArrayResponse xmlns:ns1="http://db.bioinfo.rzg.mpg.de">
       <ns2:StringArray soapenc:arrayType="xsd:string[4]" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://arrays/java/lang">
       <item>one</item>
       <item>two</item>
       <item>three</item>
       <item>jboss47</item>
       </ns2:StringArray>
       </ns1:hellostringArrayResponse>
       </soapenv:Body>
      



      If I use a wrapper as returntype (MyStringArray.java), rpc/lit is used:
       <soapenv:Body>
       <ns1:hellostringArrayWRAPPEDResponse xmlns:ns1="http://db.bioinfo.rzg.mpg.de">
       <ns1:MyStringArray>
       <stringArray>one</stringArray>
       <stringArray>two</stringArray>
       <stringArray>three</stringArray>
       <stringArray>jboss47</stringArray>
       </ns1:MyStringArray>
       </ns1:hellostringArrayWRAPPEDResponse>
       </soapenv:Body>
      



      I think the same happens with ACustomObject[].

      Question:
      Is it possible at all to use rpc/lit with return types String[], ACustomObject[] (without wrapping them !!!)?
      [If yes:]What do I have to do to encode them correctly with rpc/lit (perhaps add a typemapping in the ws4ee-deployment.xml -> which (De)SerializerFactory class?)?
      [If no:] Please tell me so!


      Thanks for any comments & help!

        • 1. Re: Array wrapping a MUST when using rpc/lit ?
          fpitschi

          I think I found out by myself:

          If you use (unwrapped!) String[], Object[], ... as parameters or return values in the ws-methods of your SEI, and use wscompile to generate the wsdl, the following happens: new complextypes ("StringArray", "NameofObjectArray") with special namespaces (e.g. "http://arrays/java/lang") are defined in the wsdl, and the corresponding messages use these types. In the generated jaxrpc-mapping.xml, these new namespaces are mapped to java-package-names (e.g. ._arrays.java.lang). These packages don't exist, and the wrapper classes (StringArray.java) also don't exist, their names were simply added to the wsdl - you get a warning when starting the server:

          [JavaWsdlMapping] Cannot find jaxrpc-mapping for type: {http://arrays/java/lang}StringArray

          Now, it looks like if these "invented" array-wrappers can't be found at runtime, jboss takes the rpc/enc-style to (de)serialize the arrays. If you use jboss on server & client side: no problem, because both sides do the same and understand each other ;-) But the SOAP-message of course is not strict rpc/lit, because the arrays are rpc/enc.

          Dirty solution: You can retrieve the wrappers by using wscompile. Then create the right packages / directory-structure looking at the wsdl & jaxrpc-mapping.xml for them. (I did not have insert type-mappings in the jaxrpc-mapping by hand to get everything running, but if you want to be on the safe side...).

          Better solution: Right from the start, define a wrapper-class for every bare array you want to use, and use this wrapper class as input or return parameter instead of the original array.


          Hoping not to cause too much confusion...
          Florian Pitschi

          • 2. Re: Array wrapping a MUST when using rpc/lit ?
            thomas.diesler

            When a wsdl message part references a type or element in schema it always points to a complex type that defines the array. Every complex type is always mapped to a java bean. So yes, you will have a wrapper.