SOAP engine design ideas
From the inside out (general idea)
The goal of soap is to call a remote method.
For the core part, the reflection mechanism must be used to call methods in the class.
Therefore, a class name, method name, parameter list (including the number/type of parameters), and parameter value are required.
To receive a SOAP message, you must first parse it: the parsing is to convert it from the SOAP message (text) to the envelope object.
Processing is required after resolution: extract useful information and obtain the class name and parameter value, because the remote transmission process uses the string format, however, to know the specific type, it is not that simple. here we need to process a description file.
Here is the core part, and we can expand it out, we can think of the need to receive and send this message. Soap messages are sent and received by constructing XML for transmission, Because XML is a common message transmission format, which is generally supported by hardware. There are two transmission modes: socket and web containers can use existing containers such as Tomcat to create a web project, that is, to receive messages through servlet.
The above is mainly to receive soap messages, the following is to send soap messages, and the above process is reversible.
The first step is to construct an envelope object and put the result into the object. In this process, Java-type data must be converted into XML elements (this also requires an intermediate type conversion mechanism ). Converts an envelope object into a string and sends it to the client to return the result.
An intermediate type converter is used to convert the sending and receiving parameter types and strings. Therefore, a separate type converter and an abstract parent class can be designed, which contains two methods, type conversion during parsing and sent to the client. Subclass inherits the parent class and implements the corresponding method. It can easily convert different types through the configuration file (similar to the factory mode.
The classification name in the core Department is obtained: because the service is a unique URL, on the server side, after the service is published, the class name processed by the service can be obtained through the one-to-one correspondence between the class name and URL, or the configuration file can be used.
To publish a service, you must specify the service name and URL (corresponding to the corresponding class) the order and type of parameters in the method (information about the services to be published in the intermediate type converter ).
------- My simple understanding. If you have any questions, you can discuss them together ~~~ Welcome contact email: zuowangxi@163.com