Can anyone please help me on below?
I have a WSDL and some XSD files used in it. I have to create the webservice and client to test them on local Tomcat machine.
What I have done so far:
-
Using
cxfinmavenI have created the Java source files from WSDL. -
I have created a new implementation class for the interface (interface generated from WSDL file).
-
Then created the WAR file of the above project and deployed on Tomcat. I can test them and they are running fine.
My question is if this is the right way of doing this ??
Also, how can I auto-create client Java sources to test this webservice?
Thanks
Create 3 maven projects:
1) Web service client project. Use CXF’s wsdl2java codegen maven plugin to generate the client code. It works best to have the client turned into a nice, neat little jar you can include in other projects.
2) Web service server interface project. Same procedure, just have maven generate the server code.
3) A third project which includes the jar from #2, your code that implements the details and builds the war with all dependencies and the CXF configuration.
This is more or less how I did this very thing recently. CXF had an issue with its codegen plugin which forced me to generate the impl during the server code generation. That’s no big deal. That meant there was a stub impl in jar #2. The way I got around that was I just created another bean that implemented the main service interface and had NetBeans generate all of the stubs for me again (and implemented each one).
It’s especially helpful if you use NetBeans and its maven plugin during this.
EDIT: I saw that you are using Eclipse, not NetBeans. To each his own, but NetBeans is a lot easier to do this sort of thing with. In fact, NetBeans and maven play a lot nicer together than anything I’ve seen with eclipse and maven. NetBeans now can treat maven projects literally like its own native projects.