WebService implementation: 1. Use the Java JDK Web Service API to implement 2. Use CXF to combine spring
I. Using JDK Web Service API methods
① creates an interface that uses the @webservice () annotation to indicate that the Java interface is an interface for the WebService service
② creates an implementation class that implements the interface, and also uses @webservice (Endpointinterface indicates an access point interface) annotation to indicate that the Java class is the implementation class for the WebService service interface.
How to create a client in the same project
URL: Create URL object from URL
QName: Creates a QName object based on the namespace and the name of the service in the WSDL file
Service: Creating Service objects
Obtaining service Interfaces for server-side publications based on the service object
Invoke the method provided by the service interface
Generating client code using DOS commands
-D: Specifies the file directory where client code is generated
-keep: Generating Source code files
-verbose: Generate detailed information
-P: Specifies the package name of the generated code file
Two, use spring and cxf combine to realize webservice
Download the compressed package
To import a jar package from a compressed package into a project
1. Create a Service interface class
2. Create the implementation class for the service interface
To configure the contents of the Spring.xml file:
Configuring Web.xml Files
Add Project to Tomcat, start service, enter in browser
HTTP://127.0.0.1:315/CXFWEBSERVICE/SERVICES/MYSERVICE?WSDL IP Address + port number + project name +CXF URL map configured in Web.xml + Posted service address
The format for saving the WSDL file file is XML
In DOS, switch directories to the directory below
Enter the following command:
-P: Specifies the package name of the build file
-D: Specifies the directory of the generated file
-verbose: Generate detailed information
"C:\myService.xml" is the path to the saved Wsdl.xml
Create a client project to copy the generated files into the project
The structure of the project is:
Methods to invoke service interfaces provided by the service side
The following results are obtained: