Tech - Programming
By: - at May 27, 2013

SOAP: Simple Object Access Protocol - Explanation

Network of Electronic DevicesSOAP (Simple Object Access Protocol) is a simple and light protocol for the exchange of information. SOAP differs from RMI, CORBA and COM because it concentrates the information and uses the principle of self-describing data. SOAP is part of the communication layer of Web Services. The strength of this protocol lies in its universality and flexibility. It defines the structure of XML messages used by applications to communicate with each other. SOAP appears as the centerpiece among all the protocols mentioned. SOAP is very complex if we wanted to detail all the specifics. We will only discuss the most used.

RPC and SOAP protocols
SOAP is one of the object-oriented communication protocols, taking the traditional principles of RPC (Remote Procedure Call) of the previous protocols, except that RPC defined by SOAP can solve certain problems raised by technologies such as CORBA or DCOM for distributed applications over the internet. Indeed, the RPC is often difficult to implement, and exchanged messages do not pass the firewall. In addition, they are not adapted to the needs of distributed applications on the Internet, where the only requirement should be to use the http protocol (in order to cross the firewall) applications. This is the aim of the SOAP standard, which has a policy of exchanging HTTP messages (or SMTP) whose body is an XML file. SOAP is based on XML-RPC specification. SOAP does not therefore disrupt the architecture of communication possibly existing in network of the company. Rather, the approximation of principles of SOAP from those of other RPC facilitates the integration of different protocols and provides an excellent interoperability at a low cost at the junction of the intranet and the Internet.

Generalities
soap generalitiesCommunication with Web Services is through the SOAP protocol. The SOAP specification highlights HTTP (rather than other transport protocols such as SMTP, FTP, POP3 and NNTP) as the preferred transport protocol of SOAP messages. Early versions of SOAP are mainly interested in the PRC through the Web, from where the primary purpose of SOAP: the RPC over HTTP. The arrival of new actors like IBM in the group of SOAP specification led to enrich SOAP ambition - and we saw a first demonstration of SOAP over SMTP, for example. SOAP can be used:

  • for calling methods (SOAP RPC)
     
  • to exchange messages (SOAP Messaging) SOAP defines the primary structure of the message, called "envelope", which contains two parts:
     
  • the header (Header): Optional
     
  • the body (Body): required

SOAP also defines the encoding for different types of data which is based on the W3C XML Schema technology. The data can be (integer string, float, ...) simple or compound.

SOAP messages SOAP governs data format at the time of sending / receiving. We name the traffic in several different types:

  • Messages
     
  • Envelopes

All SOAP messages contained in XML document are called envelopes that are containers of a SOAP message. An envelope is the first element in XML document that represents a SOAP message. It is this principle of neutrality that allows mobility of Web Services technology. The envelope being formatted according to the specifications of SOAP, the sender and the consumer can totally be written on different platforms without any problem.

HTTP requests
HTTP requests are to have a methodology request, a request URL that specifies the headers and the body of the stream sent. SOAP messages are transmitted through HTTP and allow full interoperability between clients and Web Services. When sending an HTTP request, the header field must be set to "SOAPAction:" so that the message be treated as a SOAP message.

  • GET - returns the resource identified by the request.
     
  • HEAD - returns the header identified by the request.
     
  • POST - sends values without size limit to the server.
     
  • PUT - stores a resource for the query.
     
  • DELETE - delete the resource identified by the request.
     
  • OPTIONS - returns HTTP methods supported by the server.
     
  • TRACE - returns the contents of the headers used with the TRACE option.

HTTP 1.0 includes only the GET, HEAD, and POST methods. Although J2EE servers require only HTTP version 1.0, many servers support the HTTP version 1.1.

POST / HTTP/1.0 LocalWeather1
Host: www.mystream.com
Content-Type: text / xml; charset = "utf-8"
Content-Length: 300
SOAPAction: "WeatherStation1"
<SOAP-ENV: Envelope
xmlns: SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV: encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body>
<m:GetCurrentTemperature1 xmlns:m="WeatherStation1">
<m:scale> Celsius </ m: scale>
</ m: GetCurrentTemperature1>
</ SOAP-ENV: Body>
</ SOAP-ENV: Envelope>

HTTP responses
HTTP responses using the same process.
An HTTP response contains:

404 response pop-up

  • the result code
     
  • the header
     
  • the body Here are some errors identified by a specific number on the HTTP protocol:
     
  • 404 - indicates that the requested resource is unavailable.
     
  • 401 - indicates that the request requires HTTP authentication.
     
  • 500 - indicates an internal error in the HTTP server.
     
  • 503 - indicates that the server is overloaded.

HTTP/1.0 200 OK
Content-Type: text / xml; charset = "utf-8"
Content-Length: 307
<SOAP-ENV: Envelope
xmlns: SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV: encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:GetCurrentTemperatureResponse1 xmlns:m="WeatherStation">
<m:temperature1> 22.2 </ m: temperature1>
</ m: GetCurrentTemperatureResponse1>
</ SOAP-ENV: Body>
</ SOAP-ENV: Envelope>

For the reliability of the transmitted data, IBM has established a standard: HTTPR (HTTP Reliable). This standard must ensure reliable sending or receiving SOAP messages.

Namespaces
It is important to understand XML namespaces in order to understand SOAP.

<m:GetCurrentTemperature1 xmlns:m="WeatherStation1">
<m:scale> Celsius </ m: scale>
</ m: GetCurrentTemperature1>

Analyze the XML stream above, XML allows you to create variable names similar to a programming language. Here the identifier of the namespace is called "m" and this variable contains "WeatherStation1" as namespace. This principle is widely used in variable description files of data. We have an example, m: GetCurrentTemperature1 allow to identify directly the namespace with the identifier "m".

However, XML supports the namespaces by default, so you may encounter flow as that one.

<GetCurrentTemperature1 xmlns="WeatherStation1">
<scale> Celsius </ scale>
</ GetCurrentTemperature1>

SOAP RPC
Consumer Provider and Registry of SOAP RPCThe RPCs have existed for a long time. Technologies such as CORBA, DCOM or RMI provide the opportunity to develop very simple distributed architectures. Web Services show the principle based on XML. Current implementation of Web Services provides two technologies of Remote Procedure Call (RPC): SOAP-RPC and XML-RPC SOAP-RPC: based on SOAP messages that we know. XML-RPC: offers a lighter and easier library to implement than if we use SOAP. Apache offers a quality library on the site.

A SOAP service is an application whose methods are accessible through SOAP. This service can be developed in any programming language. A service is accessed through a unique identifier of type URN . In Java ,any class can be made accessible through SOAP (using Apache SOAP). When calling a method on the deployed service, it is the corresponding method of the Java class that is executed.

The following example is a Java class that we want to make ​​accessible through SOAP with id "URN: Echo1"

public class Echo1 {
public String echo1 (String expression) {
return "Message received:" + expression;
}
}

Request / response SOAP:
To call the operation "echo1", the identifier of the remote object is specified in the SOAP Body of the request, the operation to be performed and any parameters:
Details of the request:

  • <m:echo1 xmlns:m="urn:Echo1">:the defined namespace has the service identifier as URN ("urn: Echo1"). The name of the element (echo1) is the name of the method to execute;
     
  • The call parameters of the method are then added one after the other. Here there is only one parameter: "expression" of type string.

SOAP-ENV: Body>
<m:echo1 xmlns: m = "urn:Echo1">
<expression type= "xsd:string">
Hello World
</ expression >
</ m: echo1>
<SOAP-ENV: Body>

After calling echo1 method, A SOAP message is then sent to the SOAP service. The service executes the method specified in the request and then returns a SOAP message whose Body contains the result of the operation:

The result is contained in a <return> element:

  • The type attribute specifies the return type of the method executed.
     
  • The content of the element is the result of the execution of the method.

<SOAP-ENV: Body>
<m: echo1 xmlns: m = "urn: Echo1">
<return type="string">
message received: Hello World
</ return>
</ m: echo1>
</ SOAP-ENV: Body>


 

 

 

 

Programming
Introduction to Java EE (Part 1)
How the Google App Engine Works
WSDL - Web Service Description Language
SOAP: Simple Object Access Protocol
Initiation to Cryptography and Encryption to Secure Data
Introduction to Design Patterns in Java
How To Write Efficient Programs in Java
Proper Management of Logs in .Net
How To Remove FaceBook Action Ids From URL

Programming


Copyright 2017 YurTopic All rights reserved.

Protected by Copyscape Online Plagiarism Software

There has been a total of

hits counter
Unique Visitors to YurTopic
(Since January 1st 2013)

About  |  Terms and Conditions  |  Contact