Unable to generate Java SOAP stubs using wsimport

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
User avatar
talha06
Posts: 25
Joined: Sat Sep 13, 2014 3:02 am

Unable to generate Java SOAP stubs using wsimport

Postby talha06 » Wed Mar 23, 2016 12:06 pm

Hi everyone,

I am not able to generate Java SOAP stubs using wsimport; getting an error like this:

Code: Select all

"A class/interface with the same name "x.y.z.DistributionListBy" is already in use. Use a class customization to resolve this conflict."


Any recommendations to solve this issue will be appreciated.
Thanks in advance.


User avatar
Gren Elliot
Zimbra Employee
Zimbra Employee
Posts: 183
Joined: Tue Jun 10, 2014 4:45 am

Re: Unable to generate Java SOAP stubs using wsimport

Postby Gren Elliot » Wed Aug 03, 2016 11:18 am

You need to specify bindings. I use 2 files:

Code: Select all

<jaxws:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <jaxws:package name="generated.zcsclient.ws.service" />
    <!-- jaxws:enableAsyncMapping>true</jaxws:enableAsyncMapping -->
</jaxws:bindings>


and:

Code: Select all

<jaxb:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" version="1.0">
    <jaxb:globalBindings underscoreBinding="asCharInWord" />
    <jaxb:bindings schemaLocation="https://localhost:7071/service/wsdl/zimbra.xsd"
        node="//xsd:schema[@targetNamespace='urn:zimbra']">
        <jaxb:schemaBindings>
            <jaxb:package name="generated.zcsclient.zm" />
            <jaxb:nameXmlTransform>
                <jaxb:typeName prefix="test" />
            </jaxb:nameXmlTransform>
        </jaxb:schemaBindings>
    </jaxb:bindings>
    <jaxb:bindings schemaLocation="https://localhost:7071/service/wsdl/zimbraAdmin.xsd"
        node="//xsd:schema[@targetNamespace='urn:zimbraAdmin']">
        <jaxb:schemaBindings>
            <jaxb:package name="generated.zcsclient.admin" />
            <jaxb:nameXmlTransform>
                <jaxb:typeName prefix="test" />
            </jaxb:nameXmlTransform>
        </jaxb:schemaBindings>
    </jaxb:bindings>
    <jaxb:bindings schemaLocation="https://localhost:7071/service/wsdl/zimbraAdminExt.xsd"
        node="//xsd:schema[@targetNamespace='urn:zimbraAdminExt']">
        <jaxb:schemaBindings>
            <jaxb:package name="generated.zcsclient.adminext" />
            <jaxb:nameXmlTransform>
                <jaxb:typeName prefix="test" />
            </jaxb:nameXmlTransform>
        </jaxb:schemaBindings>
    </jaxb:bindings>
    <jaxb:bindings schemaLocation="https://localhost:7071/service/wsdl/zimbraAccount.xsd"
        node="//xsd:schema[@targetNamespace='urn:zimbraAccount']">
        <jaxb:schemaBindings>
            <jaxb:package name="generated.zcsclient.account" />
            <jaxb:nameXmlTransform>
                <jaxb:typeName prefix="test" />
            </jaxb:nameXmlTransform>
        </jaxb:schemaBindings>
    </jaxb:bindings>
    <jaxb:bindings schemaLocation="https://localhost:7071/service/wsdl/zimbraMail.xsd"
        node="//xsd:schema[@targetNamespace='urn:zimbraMail']">
        <jaxb:schemaBindings>
            <jaxb:package name="generated.zcsclient.mail" />
            <jaxb:nameXmlTransform>
                <jaxb:typeName prefix="test" />
            </jaxb:nameXmlTransform>
        </jaxb:schemaBindings>
    </jaxb:bindings>
    <jaxb:bindings schemaLocation="https://localhost:7071/service/wsdl/zimbraRepl.xsd"
        node="//xsd:schema[@targetNamespace='urn:zimbraRepl']">
        <jaxb:schemaBindings>
            <jaxb:package name="generated.zcsclient.replication" />
            <jaxb:nameXmlTransform>
                <jaxb:typeName prefix="test" />
            </jaxb:nameXmlTransform>
        </jaxb:schemaBindings>
    </jaxb:bindings>
    <jaxb:bindings schemaLocation="https://localhost:7071/service/wsdl/zimbraSync.xsd"
        node="//xsd:schema[@targetNamespace='urn:zimbraSync']">
        <jaxb:schemaBindings>
            <jaxb:package name="generated.zcsclient.sync" />
            <jaxb:nameXmlTransform>
                <jaxb:typeName prefix="test" />
            </jaxb:nameXmlTransform>
        </jaxb:schemaBindings>
    </jaxb:bindings>
    <jaxb:bindings schemaLocation="https://localhost:7071/service/wsdl/zimbraVoice.xsd"
        node="//xsd:schema[@targetNamespace='urn:zimbraVoice']">
        <jaxb:schemaBindings>
            <jaxb:package name="generated.zcsclient.voice" />
            <jaxb:nameXmlTransform>
                <jaxb:typeName prefix="test" />
            </jaxb:nameXmlTransform>
        </jaxb:schemaBindings>
    </jaxb:bindings>
</jaxb:bindings>


This is a snippet of an ant build file for ZimbraSoap we use (only works with Java 7 and earlier):

Code: Select all

     <wsimport   wsdl="${xml.schema.dir}/@{svcname}.wsdl"
                    destdir="${wsdl.test.classes.dir}"
                    sourcedestdir="${wsdl.test.src.dir}"
                    keep="false">
                    <!-- package="com.zimbra.@{pathelem}client.wsimport.generated" -->
                    <binding dir="${wsdl.test.src.dir}" includes="*-@{pathelem}.xml"/>
            <produces dir="${wsdl.test.src.dir}"
                includes="com/zimbra/generated/@{pathelem}client/**/*.java"/>
        </wsimport>


As part of the migration of our source to git, I'm hoping that the zm-wsdl-test git repository will be posted to github in the nearish future, which would be a good reference point for something that works with Java8

Return to “Developers”

Who is online

Users browsing this forum: No registered users and 3 guests