I really hate dealing with the JAXB customizations. :-) With the recent versions of CXF, you can TRY passing the -autoNameResolution to wsdl2java (probably via extra args setting in the pom). That may make it automatic. Basically, it installs a name resolver that will automatically resolve various types of conflicts. It cannot get all of them, but at least it covers most cases that hit this error.
Dan On Wed May 27 2009 7:55:47 pm Thomas Fischer wrote: > Hi, > There is a WSDL file generated for a .NET web service. When wsdl2java maven > plugin is run to generate a CXF client, the plugin fails due to a name > collision. The WSDL has elements that only differ in case. JXB is case > insensitive. The cfx-codegen-plugin suggests to use a class customization. > Even there are similar examples for class customizations online, I haven't > been able to get mine to work. > > Output of Maven cfx-codegen-plugin: > [INFO] Thrown by JAXB : A class/interface with the same name > "com.sonicApi.Creat ePassResponse" is already in use. Use a class > customization to resolve this conf lict. > > > 1. Attempt at class customization: > <jaxws:bindings version="1.0" > xmlns:jxb="http://java.sun.com/xml/ns/jaxb" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:s="http://www.w3.org/2001/XMLSchema" > xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" > xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" > wsdlLocation="sonic-api.wsdl"> > > <jxb:bindings > node="wsdl:definitions/wsdl:types/s:sche...@targetnamespace='http://www.cin >emanow.com/api/']"> <jxb:bindings > node="s:eleme...@name='createPassResponse']"> <jxb:class > name="CreatePassResponseLowerCase"/> > </jxb:bindings> > </jxb:bindings> > </jaxws:bindings> > > Result: Still the same error message > > > > 2. Attempt at class customization: > <jaxws:bindings version="1.0" > xmlns:jxb="http://java.sun.com/xml/ns/jaxb" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:s="http://www.w3.org/2001/XMLSchema" > xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" > xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" > wsdlLocation="sonic-api.wsdl"> > > <jaxws:bindings > node="wsdl:definitions/wsdl:types/s:sche...@targetnamespace='http://www.cin >emanow.com/api/']"> <jaxws:bindings > node="s:eleme...@name='createPassResponse']"> <jaxws:class > name="CreatePassResponseLowerCase"/> > </jaxws:bindings> > </jaxws:bindings> > </jaxws:bindings> > > Result: Different error: > [INFO] Thrown by JAXB : Unexpected <jaxws:bindings> appears at line 0 > column 0 o f schema > file:/C:/stuff/apache-maven-2.1.0/playground/cxfspring/cxf-spring/src/m > ain/wsdl/sonic-api.wsdl#types1 > > > > 3. Attempt at class customization: > <jaxws:bindings version="1.0" > xmlns:jxb="http://java.sun.com/xml/ns/jaxb" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:s="http://www.w3.org/2001/XMLSchema" > xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" > xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" > wsdlLocation="sonic-api.wsdl"> > > <jaxws:bindings > node="wsdl:definitions/wsdl:types/s:sche...@targetnamespace='http://www.cin >emanow.com/api/']"> <jaxws:bindings > node="//s:eleme...@name='createPassResponse']"> <jaxws:class > name="CreatePassResponseLowerCase"/> > </jaxws:bindings> > </jaxws:bindings> > </jaxws:bindings> > > Result: Yet another error: > [INFO] Could not find any node with the XPath expression: > //wsdl:definitions/wsd > l:types/s:sche...@targetnamespace='http://www.cinemanow.com/api/']///s:elem >ent[@ name='createPassResponse'] > > > SUMMARY: I have run a lot more attempts at translating one of the colliding > element names to something else. Yet, all of them provide only errors that > don't point to a solution. How can the XML elements be properly name to > classes: createPassResponse -> CreatePassResponseLowerCase > CreatePassResponse -> CreatePassResponseUpperCase > > > Thomas > > The information transmitted is intended only for the person or entity to > which it is addressed and may contain confidential and/or privileged > material. If the reader of this message is not the intended recipient, > you are hereby notified that your access is unauthorized, and any review, > dissemination, distribution or copying of this message including any > attachments is strictly prohibited. If you are not the intended > recipient, please contact the sender and delete the material from any > computer. > -- Daniel Kulp [email protected] http://www.dankulp.com/blog
