This discussion is archived
4 Replies Latest reply: Jan 8, 2013 5:17 AM by user696 RSS

Can clientgen generate separate package for imported schema?

ing Newbie
Currently Being Moderated
Hi,

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,

Helen
  • 1. Re: Can clientgen generate separate package for imported schema?
    ing Newbie
    Currently Being Moderated
    Hi,

    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"
    node="//xs:schema/xs:import[@namespace=’http://examples.webservices.org/complexservice’]">
    <jaxb:schemaBindings>
    <jaxb:package name="examples.jaxb"/>
    </jaxb:schemaBindings>
    </jaxb:bindings>


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


    Thanks,

    Helen
  • 2. Re: Can clientgen generate separate package for imported schema?
    user696 Explorer
    Currently Being Moderated
    <project>
    <taskdef name="clientgen"
    classname="weblogic.wsee.tools.anttasks.ClientGenTask" />

    <target name="build_client">
    <clientgen
    wsdl="client/TestService.wsdl"
    destDir="client/output/clientclasses"
    type="JAXWS">
    <binding dir="client" includes="Custom_jaxb.xbd"/>
    </clientgen>
    </target>

    </project>

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



    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:schemaBindings>
    <jaxb:package name="examples.jaxb"/>
    </jaxb:schemaBindings>
    </jaxb:bindings>

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

    </jaxb:bindings>

    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.
    http://docs.oracle.com/cd/E24329_01/web.1211/e24964/data_types.htm#i216298


    Regards,
    Sunil P
  • 3. Re: Can clientgen generate separate package for imported schema?
    ing Newbie
    Currently Being Moderated
    Sunil,

    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,

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

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points