Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two classes have the same xml type name

When I try to publish my Workspace in RAD, I get this error "Two classes have the same xml type name", probably because the same class name exists in the same package, but in two different jars. And it seems like that the @XmlType annotation needs to have distinct values for its attributes name and namespace in the sources of these classes. I tried wsdl2java available in Apache CXF, but I'm not able to make it generate this namespace attribute. I tried fiddling with the -p package option, but that's only for placing the generated sources in the specified package.

Any ideas how to generate this namespace attribute for each element encountered in the wsdl? TIA.

like image 760
asgs Avatar asked Feb 14 '11 11:02

asgs


2 Answers

thanks to Daniel's anwser:

CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements

i learned there is a parameter -xjc-npa for wsdl2java which helped me. This will add XmlType.name and XmlType.namespace annotations to the generated classes so it won't be a problem if you have same class names but in different namespaces

like image 122
john Avatar answered Oct 17 '22 23:10

john


I ran into this for an object named "SubmitDataResponse" that I was using as a return object from my web service method named "submitData". When I tried renaming the object, the error went away. It seems to me that CXF is creating its own return object based on the method name (in this case submitData() -> "SubmitDataResponse"). You may want to try renaming the class and see if you are having the same issue. Perhaps someone can chime in with a way to keep our class named the way we want them to (probably with some annotation).

I hope this helps.

like image 39
GiantLeprechaun Avatar answered Oct 17 '22 22:10

GiantLeprechaun