4 Replies Latest reply on Apr 11, 2008 11:09 AM by Ryan Carmichael

    Web services using common complex types

    Ryan Carmichael Newbie

      Although I am an experienced programmer, I have to admit I am relatively new to Web Services and XML in general, so please bear with me...

      Let's say I have two web services, WS_A and WS_B. They both reference POJO_C (let's say both WS_A and WS_B have a function called getC that returns POJO_C). I annotate WS_A and WS_B with @WebService and deploy them and JBoss provides the web services as intended.

      However, when I generate client stubs (using wsimport), I put WS_A and WS_B in different packages. Both of those client packages end up having an object 'C' with different package names, so that WS_A.C != WS_B.C, even though I might want to use them interchangeably.

      Is the solution to this problem providing custom bindings to wsimport that moves 'C' into the same package when I run wsimport on both web services? I would think that maybe there is some way to tell JBoss that C is a shared object and put it into a XSD or something that both web services could share.

      I know this is a simple thing, thanks for the help.

      - Ryan

        • 1. Re: Web services using common complex types
          Stathis Rouvas Newbie

          I am having the same problem here and have resorted to convert the complex object (POJO_C in your example) into a byte[] which, of course, discards all information about it actually being a POJO_C type of object.
          IMHO, this is a big downside, but I have been unable to find a better solution.


          • 2. Re: Web services using common complex types
            Thomas Diesler Master

            You can use JAXB binding customizations to map package names to namespaces

            • 3. Re: Web services using common complex types
              Ryan Carmichael Newbie

              Thanks for confirming the fact that customizations is the way to go Thomas, I just wanted to see if there was an easier way. It would seem like I should be able to provide a namespace for POJO_C so that this could be done automatically, but I can handle the manual way. Thanks again!

              • 4. Re: Web services using common complex types
                Ryan Carmichael Newbie

                Just to update, I figured out that if I specify @XmlType(namespace="...") on my @Entitys that the web services are using, wsimport (if you don't use the -p option) would do what I want for me without having to specify JAXB customization files.

                I still think that it would be neat if I could somehow annotate that I want specific classes to be packaged into an XSD and then referenced from the WSDL. Then multiple WSDLs share a common XSD. I'm sure this is possible if you're starting from WSDLs and generating java classes, but in my case I'm starting with POJO @Entities and @Webservices, JBoss is generating the WSDL, then I'm using wsimport to generate client stubs.

                Anyway, what I mentioned is probably not a JBoss feature request, more of a JAXWS request. Thanks again for the replies. If anyone knows how to do this "common XSD" thing from simple annotations already, I'd love to know.