3

I would like to change the package name of all the classes that are in a schema. Unfortunately I cannot use the element of jaxws-maven-plugin as I have got a WSDL and more schemas in it.

<definitions ...>
  <types>
    <s:schema ...>
    </s:schema ...>
    <s:schema ...>
    </s:schema ...>
...

I decided to use JAXB binding file but I cannot modify the package name with it. This is my binding file:

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

<!--jaxws:bindings wsdlLocation="MYWSDL">
    <jaxb:bindings node="wsdl:definitions/wsdl:types/xs:schema/xs:element[@name='reserveAppointment']">
        <jaxb:package name="WWWWWWW"/>
    </jaxws:bindings>

</jaxws:bindings-->


<jaxws:bindings wsdlLocation="MYWSDL" node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://www.openuri.org/']">
    <jaxb:package name="WWWWWWW"/>
</jaxws:bindings>


<!--jaxws:bindings wsdlLocation="MYWSDL">
    <jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://www.openuri.org/']">
        <jaxws:bindings node="//xs:element[@name='reserveAppointment']">
            <jaxb:package name="aaaaa"/>
            <jaxb:class name="WWWWWWWW"/>
        </jaxws:bindings>
    </jaxws:bindings>
</jaxws:bindings-->


</jaxb:bindings>

I was trying more bindings but I couldn't manage to do that. I tried to change the package name of one element too. This is my WSDL:

<definitions ...>
<types>
<s:schema ...>
  <s:import namespace="XXX1"/>
  <s:element name="reserveAppointment">

How could I modify the package name with JAXB binding?

What was a surprise to me is that I could change the package name with embedding JAXB binding declaration.

<s:schema .... xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0">
    <s:annotation>
        <s:appinfo>
            <jaxb:schemaBindings>
                <jaxb:package name="wwwwwwwwwww"/>
            </jaxb:schemaBindings>
        </s:appinfo>
    </s:annotation>
    <s:import namespace="http://www.bt.com/eai/hub/or/GenericCPWSHubService"/>
    <s:element name="reserveAppointment">
...

However I wouldn't want to change the WSDL of a third-party service as I am not quite aware of what can cause if I want ot call it. Will this annotation/appinfo element change the WSDL or this is just a hint to the JAXB compiler? Thanks!

Viktor
  • 1,325
  • 2
  • 19
  • 41
  • Does it work if you add a `/` to the front of those XPaths, e.g. `node="/wsdl:definitions/wsdl:types/xs:schema/xs:element[@name='reserveAppointment']"` ? – Ian Roberts Dec 14 '12 at 16:31
  • Thanks Ian, unfortunately it doesn't. I found some blog entries that referred to omit the leading '/' but I tried both ways. – Viktor Dec 14 '12 at 16:44

0 Answers0