preface
WebService is an application program component designed to develop distributed interactive operation in order to support the operation interaction between machines on the network. It is usually defined as a set of modular APIS, which can be called through the network to execute the request service of the remote system. XML is the foundation of WebService. At the same time, almost all data types in WebService are supported.
CXF is a WebService framework. In production environment, we usually use the framework for development. This framework simply simplifies the development of WebService, and also adds interceptors. This article will take you through a quick implementation of a WebService using Apache CXF.
Public account: “Asanha’s IT Hut”
1. Start with an introduction to the use of interceptors
Requirement: We need to know the format of the data that the client passes to the server, and the format of the data that the server receives from the client.
“Interceptor:”
-
Client-side interceptor
-
Client-side inbound interceptor
-
Server-side egress interceptor
-
Inbound interceptor for the server
-
What does ** “client-to-server” data look like? Use client-side egress interceptors
-
What does the server receive from the client look like? Use server-side inbound interceptors
-
What does ** “data” ** look like? Log interceptors are provided in our CXF
“Implementation function:”
1: Add a log interceptor to the client
The format of the data that the client passes to the server
2: Add interceptor to server
The server receives the following information
2, develop a permission authentication WebService
Requirement: The WebService can only be accessed if the user is Qianyu and the password is 123
Logic (Select the client’s outgoing interceptor to add the following)
“Problems with custom interceptors:”
“Custom client interceptor:”
“Custom server interceptor:”
“Add this custom interceptor on the client and server side:”
“Test:”
3. Spring integrates the CXF framework
“Guide package:”
“Write configuration files for the Server:”
Decompress the cxf.jar file and copy the following files to the resource directory:
“Server-side testing:”
Import package on client side (same as above) :
“Generate call code:”
“Write a client configuration file:”
“Test:”
This article uses Apache CXF framework to develop WebService introduction to end here, will publish more about WebService series more articles, thank you for your support!
“Like” to prove you still love me