You are here: Home > WebServices with Java, Axis, XDoclet and Eclipse > Use web services | deutsch | ||||
WebServices with Java, Axis, XDoclet and EclipseEffective WebServices Development |
There are several possibilites to access web services from Java. The easiest way is to generate a client stub directly from the wsdl description. This stub represents the web service on the client side. You can use this stub exactly like every other java class, the fact that a web service is working behind the scenes is not noticeable[4]. The Axis framework comes with the tool called „WSDL2Java“ for generating those stubs. Since direct calling is nevertheless rather pedantic, we let that to the Lomboz plugin:
You can either read the wsdl file from the filesystem and save the file with the browser. Or you can alternatively use the url http://localhost:8080/axis/services/Version?wsdl directly:
If you check „create Unittest“, Lomboz will also generate a unit test testing the web service. This is a simple way to show how to use the generated classes. The test class requires junit.jar to be added to the project libraries because it makes use of it.
Subsequently there are four new source files in the indicated package, that together enable the access to the „version“ web service:
The fifth file is the test case, which is calling the web service. To run this test case, select the resource VersionServiceTestCase.java and choose „Run / Run as ... / JUnit TestCase“ from the menu bar.
[4] This is not completely correct, since by the remote procedure call certain exceptions cannot be avoided.
First test |
| | |
Create web services |