1. Building SOAP WebServices - Overview

SOAP was designed to be language, transport, and platform independent and an alternative to older middleware technologies such as CORBA and DCOM. It also

is designed to be extensible. WS-* Standards: WS-Addressing, WS-Policy, WS-Security, and so on are all built on the SOAP protocol.

 

Web services built using SOAP, WSDL, and XML schemas have become the standard for exchanging XML-based messages. Spring Web-Services

Advances SOAP service development (by providing a complete set of APIs and configurations for flexible web service creation).

 

MessageDispatcher is the core of Spring Web-Service, it forwards Web service messages to registered endpoints. In Spring-WS,

Request/response messages are wrapped in a MessageContext object, which is passed to the MessageDispatcher. When a message arrives,

MessageDispatcher uses the request object to get the endpoint, then gets the endpoint's interceptors and calls them on them

Use the handleRequest method. An interceptor is to perform some operations before (request) and after (response) of calling an endpoint. Later,

MessageDispatcher gets the corresponding endpoint adapter. Finally the EndpointAdapter calls the endpoint's method and will respond

Convert to the desired format and set in the MessageContext.

 

Spring-WS only supports the contract-first development style, that is, the first step is to create a contract (XSD or WSDL).

The steps to build a contract-first web service with Spring-WS are as follows:

1. Definition of contract (XSD or WSDL)

2. Create endpoint: class (receive and process incoming messages)

3. Configuration of Spring beans and endpoints

 

There are two types of endpoints: payload endpoints and message endpoints.

 

The message endpoint can access the entire XML SOAP envelope

The payload endpoint only accesses the payload part of a SOAP envelope, that is, the body part of a SOAP envelope.

In future studies, we will focus on the payload endpoints.

 

To describe the creation process of the Web service, a simple fictional restaurant is used as a business scenario, which needs to accept orders from customers.

So it decided to publish its OrderService component as a Web service. For simplicity, there are only two operations:

String placeOrder(...)和boolean cancelOperator(...)

 

The domain model is as follows:



 

Subsequent studies will gradually build small parts of the project until the entire project is complete. The java project name is LiveRestaurant,

Each recipe is suffixed with _Rx.x. For example, the 1st recipe will use LiveRestaurant_R-1.1 and

LiveRestaurant_R-1.1-Client is used as the project name of server and client.

 

The goal of this chapter is to build a web service, so more emphasis is placed on explaining the server-side code and configuration. Client code is only used to

Check out the functionality of the server, and more about the client will be learned in later chapters.

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326134422&siteId=291194637