Introduction to soap (Common WebService protocols)

Source: Internet
Author: User
Introduction to soap

Information exchange between various systems within an enterprise system has always been a problem. In the past, there were solutions such as DCOM and CORBA, but they were not perfect. They were either too complicated or flawed. Currently, soap is popular (Simple Object Access Protocol, Simple Object Access Protocol ).

New concepts such as soap, Web Service, and Apache SOAP are often confusing. In my understanding, Web Service (also called Web Service) is a big concept that represents a design concept. Soap is an important part of Web services. If we compare web services to the Internet, soap can be compared to TCP/IP. Soap is a protocol rather than a specific product. Microsoft also has its own soap implementation product. Apache SOAP is a popular SOAP implementation product in Java, however, its next version has been renamed axis.

Soap uses XML files as the carrier for data transmission and uses HTTP lines. Generally, enterprise firewalls open port 80 of HTTP, so soap will not be blocked by the firewall, this is an advantage of soap.

Both sides of information transfer require support for the soap service. Because XML files are sent, the other party needs to have the soap service to receive them, and the other party will have feedback that is also an XML file, at this time, you also need to install the soap service to receive,

Soap is an XML-based transmission protocol for data encoding between applications. Initially proposed by Microsoft and userland software, with the continuous improvement and improvement, soap is soon widely used in the industry. At present, the fully released version is 1.1. During its development, the W3C XML standards Team actively promoted soap to become a true open standard. At the time of writing this document, draft soap1.2 has been published, and 1.2 has improved the relatively confusing section in section 1.1.
Soap is widely used as an important part of the next-generation cross-platform and cross-language distributed computing Web Services.
2. What is Axis

Axis is a SOAP engine launched by Apache. The axis Project is a successor to the well-known soap project of Apache. Currently, the latest version is 1.1, which is developed using Java, the C ++ version is under development. Axis V1.1 software package can beHttp://ws.apache.org/axis/dist/1_1/Download.
However, axis is not only a SOAP engine, but also includes:
An independent SOAP server
A Servlet Engine plug-in, which can be Tomcat
Support for WSDL Extension
A tool that generates the description of WSDL into a Java class
Sample Code
There is also a tool for monitoring TCP/IP packets

Ii. Installation of Axis

To use axis to develop Web Services, you must install the following software:
1. jdk1.4.2
2. A server engine that supports servlet, such as Tomcat, which is widely known.

After Tomcat is installed, extract the downloaded axis package, copy the "axis" directory under the "webapps" directory to the "webapps" directory under the tomcat installation directory.

Iii. Axis Configuration

Axis is developed based on Java and can be deployed in a variety of operating systems. You need to configure a series of system variables before using it. Assume that you have installed Tomcat 4.0 or later on the local machine, the following table lists the system variables to be configured:

Catalina_home
C:/tomcat_4_1

(This should be the installation location of Tomcat. Note that no space exists in the path name)

Axis_home
% Catalina_home %/webapps/axis

Axis_lib
% Axis_home %/lib

Axisclasspath
% Axis_lib %/axis. jar; % axis_lib %/commons-discovery.jar; % axis_lib %/commons-logging.jar; % axis_lib %/jaxrpc. jar; % axis_lib %/SAAJ. jar; % axis_lib %/log4j-1.2.8.jar; % axis_lib %/xml-apis.jar; % axis_lib %/xercesimpl. jar

Add the following to classpath:
% Axis_lib %/axis. jar; % axis_lib %/commons-discovery.jar; % axis_lib %/commons-logging.jar; % axis_lib %/jaxrpc. jar; % axis_lib %/SAAJ. jar; % axis_lib %/log4j-1.2.8.jar; % axis_lib %/xml-apis.jar; % axis_lib %/xercesimpl. jar

4. Axis Testing

After the installation and configuration are complete, test whether axis can run correctly.

Start the Tomcat server and accessHTTP: /localhost: 8080/axis/happyaxis. jspIf an error is displayed on the page, check whether the related configuration is correct. If the system component, attribute, and other parameter configuration information are correctly displayed on the page, the installation is successful. Now you can start developing your Web Services application.

5. Service Release
Axis provides two service publishing methods: instant deployment and custom deployment ).

1. Use instant release Java Web Service (JWS)

Real-time release support is one of the characteristics of Axis. Using Real-time release allows users to quickly publish a Web Service by providing the source code of the Java class that provides services. Whenever a user calls such a service, axis automatically compiles the service. Even if the server is restarted, it does not have to be processed.

To use instant release, you first need a Java source file that implements service functions, change its extension to. JWS (abbreviation of Java Web service), and then place the file in "... /Webapps/axis directory.
Here we provide a service that converts the length units from miles to kilometers. The source code is as follows:

File distance. JWS

Public class distance
{
Public double convertmile2kilometre (double mile)
{
Return mile * 1.609; // converts the distance from a mile to a kilometer.
}
}

Put it in "... /Webapps/axisHttp: // localhost: 8080/axis/distance. JWS? WSDLThe WSDL description file of the service is displayed, indicating that the distance service has been released successfully. The wdsl code described is as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
-<WSDL: Definitions targetnamespace ="
Http: // 192.168.0.26: 8080/axis/distance. JWS"Xmlns ="Http://schemas.xmlsoap.org/wsdl/"
Xmlns: apachesoap ="
Http://xml.apache.org/xml-soap"Xmlns: impl ="Http: // 192.168.0.26: 8080/axis/distance. JWS"Xmlns: INTF ="Http: // 192.168.0.26: 8080/axis/distance. JWS"Xmlns: soapenc ="Http://schemas.xmlsoap.org/soap/encoding/"Xmlns: WSDL ="Http://schemas.xmlsoap.org/wsdl/"Xmlns: wsdlsoap ="Http://schemas.xmlsoap.org/wsdl/soap/"Xmlns: XSD ="Http://www.w3.org/2001/XMLSchema">
-<WSDL: Message name = "convertmile2kilometrerequest">
<WSDL: part name = "Mile" type = "XSD: Double"/>
</WSDL: Message>
-<WSDL: Message name = "convertmile2kilometreresponse">
<WSDL: part name = "convertmile2kilometrereturn" type = "XSD: Double"/>
</WSDL: Message>
-<WSDL: porttype name = "distance">
-<WSDL: Operation name = "convertmile2kilometre" parameterorder = "Mile">
<WSDL: input message = "impl: convertmile2kilometrerequest" name = "convertmile2kilometrerequest"/>
<WSDL: Output Message = "impl: convertmile2kilometreresponse" name = "convertmile2kilometreresponse"/>
</WSDL: Operation>
</WSDL: porttype>
-<WSDL: Binding name = "distancesoapbinding" type = "impl: distance">
<Wsdlsoap: Binding style = "RPC" Transport ="
Http://schemas.xmlsoap.org/soap/http"/>
-<WSDL: Operation name = "convertmile2kilometre">
<Wsdlsoap: Operation soapaction = ""/>
-<WSDL: input name = "convertmile2kilometrerequest">
<Wsdlsoap: Body encodingstyle ="
Http://schemas.xmlsoap.org/soap/encoding/"Namespace ="Http: // defaultnamespace"Use =" encoded "/>
</WSDL: input>
-<WSDL: Output name = "convertmile2kilometreresponse">
<Wsdlsoap: Body encodingstyle ="
Http://schemas.xmlsoap.org/soap/encoding/"Namespace ="Http: // 192.168.0.26: 8080/axis/distance. JWS"Use =" encoded "/>
</WSDL: output>
</WSDL: Operation>
</WSDL: Binding>
-<WSDL: Service name = "distanceservice">
-<WSDL: Port binding = "impl: distancesoapbinding" name = "distance">
<Wsdlsoap: address location ="
Http: // 192.168.0.26: 8080/axis/distance. JWS"/>
</WSDL: Port>
</WSDL: Service>
</WSDL: Definitions>

It should be noted that JWS web service publishing is a very simple web service publishing method. You cannot use packages on the page, and because the code is compiled at runtime, therefore, after deployment, it is difficult for you to find the error.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.