• No results found

CHAPTER 3 OVERVIEW OF XML WEB SERVICES

3.3 DESCRIBING WEB SERVICES

The first mechanism that will be discussed is Web Services Description Language (WSDL). As was stated in the previous section, WSDL is the common format for

describing and publishing Web service information. Web services have been around for a long time in a very primitive form. This primitive form is difficult to program and to understand, it is inconsistent and has no standard approach for describing data. By placing the request and reply into an XML document, i.e. into the resources that are referenced by the URL’s rather than within the parameters of the URL’s, provides a modern approach to Web services. The next section will describe WSDL in more detail.

3.3.1 Web Services Description Language (WSDL)

The WSDL is the common format for describing the information of a Web service. To ensure that you don’t have to create special interactions with each server on the Web, as you would today by making use of the URL approach, Web service interface standards are needed.

WSDL elements contain two main parts, namely:

(a) A description of the data, normally in the form of an XML schema; (b) A description of the operations to be performed;

It is important that there is a description of the data so that the sender and the receiver understand the data being exchanged and it is equally important that the XML processor has a description of the operations that need to be performed, so that the receiver knows

how to process the message and that the sender knows how to send it. WSDL is typically used with SOAP.

WSDL has been recommended by the W3C (5). It has unanimous vendor support and the WSDL specification is presently the definition of a Web service description.

For communication or interaction to occur effectively between two parties, both parties have to have the same WSDL. In other words, both the sender and the receiver need to have access to the same XML schema. The sender needs to know how to format the output message correctly and the receiver needs to understand how to interpret the input message correctly. WSDL provides a common format to encode and to decode

messages to and from virtually any back-end application. This is illustrated in figure 3.4

(page 45).

Web services are normally implemented using programming languages that have been designed for interaction with the Web. Examples of such languages are Java servlets, Application Server Pages (ASP), amongst others. These languages would call a back-end program or object. To describe how Web services are implemented, lets look at a practical example.

3.3.1.1 A Practical Example

Figure 3.6 illustrates how a business can advertise a product using Web services. Let’s say, for example, that a company sells tea. They want to advertise the fact that they sell tea.

(1) The company would create a Web service, in this case by making use of an Enterprise Java Bean (EJB). In this case the WSDL repository is part of the J2EE container.

(2) There needs to be a WSDL file which provides a common format that is used for the client who needs to send messages to a server and for the server to read the message sent.

(3) The EJB is exported using a servlet over the network.

(4) The servlet “listens” to the network through either a Web server or a custom HTTP listener.

(5) The servlet accepts a SOAP message and forwards it to the beans that are represented by the WSDL file (the WSDL provides the common format).

(6) The beans in turn implement, or connect to, the specific business applications being exposed to the network, providing the information that is carried in the SOAP body as input, and returning any results back through the beans to the servlet.

Web services implementations are typically based on WSDL or represented using WSDL, i.e. new services can be generated from WSDL, or existing services can be described using WSDL.

Figure 3.6 – Using WSDL To Advertise Web Services For A Business

3.1.2 Summary

To summarize, WSDL is the format that allows a Web service to be created using XML.

3.4 ACCESSING WEB SERVICES

The second mechanism that will now be discussed is Simple Object Access Protocol (SOAP). WSDLis the format in which messages are passed between applications. To recap, a Web service is a more sophisticated way of transferring data. Instead of

making use of a URL, the message is encapsulated into an XML document using SOAP. The message is sent via the Internet, using XML technology, to another application. Both the sender and the receiver need to make use of the same WSDL in order to understand one another. WSDL allows a user to describe data. SOAP provides a level of transporting data from one place to another over the network.

As the Web is the major network in existence today, and as XML emerges as one of the major ways of representing data, it makes sense that the best way in which Web

services are transported should be a combination of the two. This is exactly what SOAP provides. It provides a way of sending and receiving XML documents over the Web by making use of a common data transfer protocol.

BUSINESS APPLICATIONS J2EE CONTAINER SOAP Web Server 1. 2. 3. NETWORK “listens” 6. WSDL files repository EJB’s WSDL 4. 5. SERVLETS

SOAP can be seen as an extension of HyperText Transport Protocol (HTTP). Instead of using HTTP to request an HTML page to be downloaded and displayed in a browser, SOAP sends an XML message via an HTTP request and receives a reply, if any, via an HTTP response. Figure 3.7 below illustrates an example of how a message is sent making use of SOAP. Figure 3.7 shows a simple application of how SOAP can be used to send a message where:

1. The message consists of an envelope, the header and a body. The

envelope is SOAP, the header being the list of devices that the message will be sent to and the body contains the message itself.

2. The message will be sent using an HTTP POST. POST allows the message to be sent, in this case the message is sent to a broadcastService.

3. Software will receive the message and it will then decode the message and execute the send request, which is the body part of the message.

Figure 3.7 – A Simple Example Using SOAP To Send A Message

HTTP Block Envelope: <env:Envelope xml ….. …..soap-envelope”> Header: <env:Header> <n:broadcastservice ….. <n:list>PDA, Cell, Email, Voicemail….. Body:

<env:Body> …..

<m:message>

Please call me urgently!!! </m:message>

Unit Of Communication (SOAP is used instead of HTTP) List Of Devices To Be Broadcasted To The Message POST /broadcastService HTTP/1.1 ….. …..

Software Receiving The Message Decode The Block

Execute Send Request

PDA Email Cellphone

1

2

WSDL describes how Web services are formatted and SOAP provides a way of sending the Web service. The third mechanism that is very important is that of the universal description, discovery, and integration (UDDI).

Related documents