Very Simple Object Access Protocol with Javaby Olexiy & Alexander Prokhorenko
The famous foreign developer website developer.com published in January 15, 2004
Before starting, I would like to make some essential descriptions on the theme and the starting knowledge of the subject and readers needed. The theme of this article is to discuss SOAP technology, we will make it easy to understand as much, so we introduced a normal "Hello World" example to show the readers how they operate, let readers know their way of operation. . I think that if the official documentation is difficult to start learning this new technology, the official document contains a lot of examples, and all features and advantages are explained, but they did not explain their way of operation. In this article, I don't plan to explain the definition of SOAP technology. We assume that readers are familiar with Java language, Web technology, with XML language, XML Namespaces, XML Schema's basis. In this case, it is understood that there will be no difficulties in this article. However, even if there is no such knowledge, you don't have to worry, we will explain as simple as possible, but you will encounter some problems and trouble when you start doing your own SOAP app. Therefore, it is necessary to spend a certain time to learn the top knowledge.
From the perspective of technology, it is necessary to mention our debugging environment. We use the Windows XP operating system with Java 2 SDK 1.4.1, Apache SOAP 2.3.1, JAF 1.0.2, JavaMail 1.3.1 and Xerces 2.6.0. The above mentioned can run normally in the Tcomcat 4.1.29 JSP / Servlet container. All software is free free software, so you can easily download them and install them on any of your favorite platforms such as Windows or UNIX. Java SDK, Jaf and JavaMail are located in Sun's official website (http://java.sun.com), other software has Down on the official website of the Jakarta project group (http://jakarta.apache.org). Maybe you have been a bit worried and uneasy when we need so many different packages (package), but in fact you should not worry about it. Once you know the foundation, then you will be quite easy to you. Install is not a difficult thing, you only need to carefully set the environment variable, such as Catalina_Home, ClassPath, Java_Home, etc., all these steps are manually. Since I just want to concentrate your attention again, you can complete the above configuration procedure. I just add some strings below to Tomcat's bin / setClassPath.bat file:
...
SET CATALINA_HOME = C: /Tomcat4.1.29
Set classpath =% java_home% / lib / Tools.jar
Set classpath =% java_home% / soap-2.3.1 / lib / soap.jar
Set classpath =% classpath%;% java_home% / javamail-1.3.1 / mail.jar
Set classpath =% classpath%;% java_home% / jaf-1.0.2 / activation.jar
Set classpath =% classpath%;% java_home% / Xerces-2_6_0 / XercesImpl.jar
Set classpath =% classpath%;% java_home% / XERCES-2_6_0 / xercessamples.jarset classpath =% classpath%;% java_home% / XERCES-2_6_0 / XML-Apis.jar
Set classpath =% classpath%;% java_home% / Xerces-2_6_0 / xmlparserapis.jar
Set classpath =% classpath%;% catalina_home% / common / lib / servlet.jar
Set classpath =% classpath%;% catalina_home% / common / lib / Tools.jar
...
If your installation path (INSTALLATION PATHS) is different from the above, you need to correct them, then close and restart Tomcat so that they take effect. In this way, you have prepared for running SOAP. But now, I have to forget the relevant technical part to learn a aoretical knowledge.
SOAP means simple object access protocol (Simple Object Access Protocol). The SOAP is very simple as its name. It is an XML-based protocol, allowing program components and applications to communicate with each other using a standard Internet protocol - http. SOAP is an independent platform that does not rely on programs, it is simple, elastic, easy to expand. Currently, applications can communicate with each other using a remote procedure call (RPC) based on DCOM and CORBA technology, but HTTP is not designed to be this purpose. RPC is very difficult in Internet applications, which will have many compatibility and security issues because firewalls and proxy servers typically block (block) of these types of traffic. The best communication method between the application is through the HTTP protocol because HTTP is supported all Internet browsers and servers. Based on this purpose, the SOAP protocol is created.
So how do they work? For example, an application (a) needs to communicate with each other with another application (b) with the help of SOAP. They will use the following frame diagram to complete this process:
This SOAP envelope is an XML document containing the following:
As you can see, it is very simple. It seems to be an ordinary envelope or your email. Do you want to see how they move? Let's come with us. In fact, there are many ways to use SOAP to create and run our own "Hello World" application, but because we have to keep it simple, I will give you a framework for how it works (Scheme).
Our "Hello World" example will contain a SOAP Service. Our SOAP Client will send their name to the SOAP Service and try to get some reply or responses. This SOAP Service requires a tool to be deployed to a SOAP Admin to relocate all requested SOAP (Proxy) RPC Router know which service they should use to operate. All in all, this is to operate in the following ways:
Translated by caiyi0903 (Willpower), 2004.1.17