1. Configure the JDK environment, open the command line, enter Wsimport carriage return can see many parameters of the command,
-S: the storage path to generate client code
-P: New packaging of generated code
These two are most commonly used.
On the command line that opens, enter: Wsimport-s/home/medees/test http://10.90.2.17:6789/hello?wsdl
-S is followed by the place where the client code is generated, and the last parameter is the publish address plus the WSDL
2. Here is the directory of my Build:
3. Copy the generated code package to the project, and mine is the folder generated in the test directory.
4. Create a new client project, copy the generated client code to the project SRC directory, the new class can be called directly, just like a local call
Package com.mess; Public class testserviceclient { publicstaticvoid main (string[] args) { Helloserviceimplservice HS=new helloserviceimplservice (); Helloserviceimpl HSI=hs.gethelloserviceimplport (); String message=hsi.sayhello ("John Doe"); SYSTEM.OUT.PRINTLN (message);} }
The output is:, the client call succeeds!
The Wsimport method of the JDK implements the WebService client invoke service