6

I have a WSDL file which imports several XML Schemas, each of them having the same namespace (let's call it A). I'm trying to use a JAXB external binding file to change the generated package name (to let's say B) for those schemas. Here is an example:

I have a POM file containing the configuration for code generation from WSDL (using the cxf-codegen-plugin).

My WSDL:

<definitions ...>
    <types>
         <xsd:schema elementFormDefault="qualified" targetNamespace="C">
             <xsd:import namespace="A" schemaLocation="SCHEMA_REF"/>
             <xsd:import namespace="A" schemaLocation="SCHEMA_REF"/>
             ...
         </xsd:schema>
    </types>
    ...
</definitions>

Here is my actual binding file which does not work at all, it seems it is not applied at all (no error message...).

<jaxws:bindings wsdlLocation="WSDL_LOCATION" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" jaxb:version="2.0">
    <jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='C']/xs:import[@namespace='A']">.
        <jaxb:schemaBindings>
            <jaxb:package name="B" />
        </jaxb:schemaBindings>
    </jaxws:bindings>
</jaxws:bindings>

As I don't have any error message in the generation maybe it is because the XPath expression used to access to the imported schema is not good...

Do you guys have any clue? I am kind of stuck here...

Thanks in advance for your inputs!

reef
  • 1,813
  • 2
  • 23
  • 36

2 Answers2

1

Try writing your bindings as-if the schema-import were merged into the WSDL document, by referencing its namespace directly:

<jaxws:bindings wsdlLocation="WSDL_LOCATION" 
        xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" 
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        jaxb:version="2.0">
    <jaxws:bindings 
node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='A']">
        <jaxb:schemaBindings>
            <jaxb:package name="B" />
        </jaxb:schemaBindings>
    </jaxws:bindings>
</jaxws:bindings>

This worked for me. Kudos to this post which demonstrates working with an imported schema.

riskop
  • 1,693
  • 1
  • 16
  • 34
javabrett
  • 7,020
  • 4
  • 51
  • 73
0

Interestingly, you've got no answers :) Unfortunately it is not possible to archive what you want. The only way is to define separate binding files for each schema file you have, that will work fine.

Stas
  • 1,707
  • 15
  • 25
  • Thanks for your answer, I am not working on this topic right now so I cannot test this solution. I will as soon as I can! – reef Jun 16 '11 at 09:33
  • One addition - you will have to use pure "jaxb" namespace for XSD files, "jaxws" is not going to work with them. – Stas Jun 16 '11 at 13:52