开发者

CXF Wsdl2Java Best Practice [closed]

开发者 https://www.devze.com 2023-03-08 15:10 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. 开发者_开发百科Closed 9 years ago.

I'm currently using cxf 2.4.0 and my code is a caller to a webservice. I was able to generate the client side java files using the cxf plugin in Maven. My question is what is the best practice for the generated files? Should I compile the generated files and package the generated class files into a single jar file or should I include all of the generated java files in the build path?


I get CXF to generate the code under target, it picks target/generated-sources/cxf by default, which is good by me. (If you're using xjc for handling a schema, it uses a similar scheme. Maven is great for conventions!)

What I sometimes do is put the generated code in its own maven module, which can sometimes simplify things; Eclipse is not entirely happy with generated source code (it doesn't like the fact that cleaning rips the source code out from under it's feet) so corralling that out of sight makes things much simpler. After all, it's just a library that happens to be generated from a WSDL document…


For generated code, I normally create a "generated" folder under "main" (main/src/java - main/generated/java) and I have CXF to generate the classes there. Then I just add the "generated" folder to the compiler source path.


Create a build task (ant/maven) that generates the code and packages the compiled code into a jar file. When the wsdl changes, you only have to re-run the build task.

If you choose to generate the source, use the Generated annotation. Most wsdl generation tools have this option.

0

精彩评论

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