Generate the WebService client as a command:
Create a project item, the client project name Ws_client, enter the JDK bin directory in the CMD interface, enter the following command
Full format:
C:\Program files\java\jdk1.7.0_80\bin>wsimport-keep-p com.javen.service-d D:\
\WORKSPACEFOREWF\WS_CLIENT\SRC http://localhost:8091/WS_WebService/server/web-publish?wsdl
The following status appears after the carriage return to indicate success!
-p com.javen.service is stored in the server synchronization code, Com.javen.service can define their own
-D d:\\workspaceforewf\ws_client\src (the absolute path of the client) puts the server's synchronized code into the client's SRC directory
HTTP://LOCALHOST:8091/WS_WEBSERVICE/SERVER/WEB-PUBLISH?WSDL, the rest of this is the service-side WSDL connection.
After success, create a test class that tests to see if data can be obtained from the server:
@Test Public voidSelectnameall () {Try{iuserservice Iuserservice=NewUserserviceimplservice (). Getuserserviceimplport (); List<User> User =Iuserservice.selectall (); for(User user2:user) {System.out.println ("Name:" +user2.getusername ()); } } Catch(Exception e) {System.err.println (E.getmessage ()); System.err.println ("Connection is denied, check whether the server is started or connected correctly"); } }
WebService client (created by command)