javaxmljaxbwsimport

wsimport : unable to rename the package name


I've a wsdl at an address like https://mycompany.com/mywspath/Documents.svc?wsdl It seems that xsd is visible at https://mycompany.com/mywspath/Documents.svc?wsdl&xsd=xsd0

giving a

wsimport https://mycompany.com/mywspath/Documents.svc?wsdl

I obtain hierararchy containing the classes related to Documents and the dependencies (com.microsoft,...)

com
-microsoft
--...
-mycompany
--...
org
-datacontract
--schemas
---...

My willing is to refactor the generated clasees in com.mycompany.mywspath to com.mycompany.mywspath.test or com.mycompany.mywspathA

This because there are other webservice that contain other definitions in the same namespace so the generated classes are stored in the same package com.mycompany.mywspath and the ObjectFactory.class obtained from the first wsimport is overwritten from the one generated from the following calls.

My willing is to avoid this binding on different packages the namespace coming from different webservices using -b option of wsimport.

I used a XML binding file like this:

 <jxb:bindings 
        jxb:version="2.1"  
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"   
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:xs="http://www.w3.org/2001/XMLSchema" 
        xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
        xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">

        <bindings schemaLocation="https://https://mycompany.com/mywspath/Documents.svc?xsd=xsd0"
                node="//xsd:schema[@targetNamespace='http://mycompany.com/mywspath']">
            <jxb:schemaBindings>
                <jxb:package name="com.mycompany.mywspath"/>
            </jxb:schemaBindings>
        </bindings>

    </jxb:bindings>

Class are originated in the same place without any modification and com/mycompany/mywspath/test is not originated.

How can I move those classes to com/mycompany/mywspath/test package ?


Solution

  • Use

    wsimport -p com.bingo.charlie YOUR_WSDL_URL
    

    to define a package for your generated files.