Soap Introduction (Webservice Common protocol)

Source: Internet
Author: User
Tags soap web services java web tomcat server log4j wsdl
Introduction to Soap

The exchange of information between systems within the enterprise system has always been a difficult problem, in the past, DCOM, CORBA and other solutions, but are not perfect, not too complex or flawed. Now, it's more popular soap (full name: Simple Object access Protocol, the easy Objects accessing protocol).

The new concepts of SOAP and Web service and Apache soap (which should not be new) are often confusing. As I understand it, Web service (also called Web Services) is a large conceptual category that presents a design idea. Soap is an important part of Web service, and if the Web service is likened to the Internet, then soap can be likened to TCP/IP. Soap is a protocol rather than a specific product, Microsoft also has its own SOAP implementation products, and Java, the more popular SOAP implementation product is Apache SOAP, but its next version has been renamed Axis.

SOAP is the carrier of data transmission through the XML file, take the HTTP line, the general enterprise's firewall all open HTTP 80 port, so soap is not blocked by firewall, this is one of the advantages of soap.

Both sides of the information transfer request to support the SOAP service, because the XML file is sent over, then the other side needs to have a SOAP service to receive, and then the other side will have feedback is also an XML file, then you also need to install a SOAP service to receive,

Soap is an xml-based transport protocol that is used to encode communication data between applications. Originally proposed by Microsoft and Userland software, soap quickly became widely available in the industry as it continued to evolve and improve, with a fully released version of 1.1. In the course of its development, the Working Group on the XML standard of the consortium actively contributed to soap becoming a true open standard. At the time of writing this document, the SOAP1.2 draft has been published, with 1.2 to 1.1 of the relatively confusing part of the improvement.
Soap is widely used as an important part of a new generation of Cross-platform, Cross-language distributed computing Web services.
2. What is axis

axis is the SOAP engine launched by the Apache organization, the Axis project is the successor to the famous Apache SOAP project, the latest version is the 1.1 version of Java development, C + + version is being developed. The Axis v1.1 package can be downloaded from http://ws.apache.org/axis/dist/1_1/ .
But axis is more than just a soap engine, it also includes:
A SOAP server that runs independently
A servlet engine plug-in, this servlet engine can be tomcat
Extended Support for WSDL
A tool to generate Java classes from a description of the WSDL
Some sample code
There is also a tool for monitoring TCP/IP packets

Ii. Installation of Axis

To apply axis to develop Web Services, you need to install the following software:
1.jdk1.4.2
2. A server engine that supports servlet, such as well-known Tomcat.

when Tomcat is installed, simply unzip the downloaded axis package and copy the "axis" directory under the "WebApps" directory to the "WebApps" directory under the Tomcat installation directory.

iii. Configuration of Axis

axis is based on Java development, can be deployed in a variety of operating systems, the need to configure a series of system variables before use, assuming that you have installed a version of Tomcat more than 4.0, you need to configure the system variables as shown in the following table:

Catalina_home
C:/tomcat_4_1

(This should be the installation location for Tomcat, note that there are no spaces in the pathname)

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

CLASSPATH Add:
%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

Iv. Axis's testing

after the installation has been configured, you should test to see if axis can run correctly.

start Tomcat server, access in browser http://localhost:8080/axis/happyaxis.jsp , if the page appears to have errors, you need to go back to check the relevant configuration is correct, if the browsing page can correctly display the system components, properties, such as parameter configuration information, the installation is successful. Now you are ready to start developing your Web Services application.

V. Distribution of services
Axis offers two modes of service publishing, one for instant release (Instant deployment) and one for custom publishing (custom deployment).

1. Use Instant publishing Java Web Service (JWS)

support for instant release is one of the features of axis, which enables users to quickly publish Web services by using instant Publishing to provide the source code for the Java class that provides the service. Every time a user invokes such a service, axis compiles automatically and does not have to do any processing on the server if it is restarted, and is very simple and quick to use.

Using instant publishing requires a Java source file that implements the service functionality first, changes its extension to. JWS (the abbreviation for the Java Web Service), and then places the file in the ".../webapps/axis" directory.
Here gives a unit of length from miles to kilometer conversion service, its source code is as follows:

file Distance.jws

public class Distance
{
Public double convertmile2kilometre (double mile)
{
return mile * 1.609; To achieve a mile to kilometer distance conversion
}
}

Place it in the ".../webapps/axis" directory by accessing thehttp://localhost:8080/axis/Distance.jws?wsdlyou can see the WSDL description file for this service, which indicates that the distance service was successfully released. 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's important to note that JWS Web service publishing is a very simple way to publish Web services, where you can't use packages on a page, and since the code is compiled at runtime, it's hard to find the error after deployment.

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.