开发者

Two classes have the same xml type name

开发者 https://www.devze.com 2023-02-10 14:14 出处:网络
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

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 see开发者_Go百科ms 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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消