4 Replies Latest reply: Jan 8, 2013 7:17 AM by User696-Oracle RSS

    Can clientgen generate separate package for imported schema?


      We have several web services that using the common schemas. The WSDLs import the common schemas from the same location.

      We use clientgen to create the client proxy and we have to give different package name for each web service. So the java classes generated for the common schemas are with different package name and packaged for each ws client jar. In a client application, I need to get the data of the common data type from one web service and then pass the date in the request of another web service call. I do not like to convert the objects of the common schema just because of their different package names. Is there a way I could generate java classes for the imported common schemas in a separate package that could be shared by multiple web service clients? I know wsimport could solve this but how to solve this with clientgen?

      Ref for wsimport: http://metro.java.net/guide/ch03.html#compiling-multiple-wsdls-that-share-a-common-schema

      Thansk a lot,

        • 1. Re: Can clientgen generate separate package for imported schema?

          I find the following in the Oracle document:http://docs.oracle.com/cd/E13222_01/wls/docs103/webserv/data_types.html#binding_declarations

          The following shows how to define the package name for an imported XML Schema:
          <jaxb:bindindgs xmlns:xs="http://www.w3.org/2001/XMLSchema"
          <jaxb:package name="examples.jaxb"/>

          But I do not quite understand it. Please advise if you have any related experience.


          • 2. Re: Can clientgen generate separate package for imported schema?
            <taskdef name="clientgen"
            classname="weblogic.wsee.tools.anttasks.ClientGenTask" />

            <target name="build_client">
            <binding dir="client" includes="Custom_jaxb.xbd"/>


            WSDL Snippet
            <xsd:import namespace="http://dataclasses.daleen.com/" schemaLocation="TestService_schema1.xsd"/>
            <xsd:import namespace="http://bea.com/" schemaLocation="TestMobileWebServicePort1.xsd"/>

            Binding files

            <jaxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">

            <jaxb:bindings schemaLocation="TestService_schema1.xsd" node="/xs:schema">
            <jaxb:package name="examples.jaxb"/>

            <jaxb:bindings schemaLocation="TestMobileWebServicePort1.xsd" node="/xs:schema">
            <jaxb:package name="examples.jaxb.package2"/>


            The above sample should generate the classes in different packages if you have multiple packages.
            The root jaxb:bindings element can contain child elements. You specify the schema node that is being customized by passing an XPath expression in the node attribute.

            Sunil P
            • 3. Re: Can clientgen generate separate package for imported schema?

              Thanks a lot!

              I tried and got the classes created for the imported common schema in the specified package only when I removed the packageName setting from the clientgen.
              Then I have 2 issues:

              1st I need to create the client classes for the service in a specific package, i.e. not the the targetnamespace by default. But when I have the packageName attribute set in the clientgen tag for this, the classes of the common schema are generated in the same package even though I have the binding configuration file to set a different package name for the imported schema.

              2nd, I set the attribute destFile="${service.name}.jar" for the clientgen to create the client jar but I should not include the classes that generated for the common schema since I have several such jars created for other web services that using the same common schema. Ideally I should have the classes of the common schema packaged in a single jar.

              How to solve the above issues?

              Thanks again,

              • 4. Re: Can clientgen generate separate package for imported schema?
                yes, you should not use packageName inside clientgen the sample code I had updated does not have the packageName.