Web Services

   

Java™ 2 Primer Plus
By Steven Haines, Steve Potts

Table of Contents
Chapter 26.  Web Architecture


The newest addition to the Web architecture field is called the Web service, or more commonly, Web services. Web services differ from other Web applications in that they normally expect to be called by another program and not by a human with a browser.

The impact of this seemingly small detail is huge. When a human is looking at a Web site, he can understand what the page is trying to convey, even if the page is formatted in one of twenty different ways. Programs, on the other hand, are very picky about the kind of data that they can accept and the manner in which it must be formatted.

Web services are the logical outgrowth of the concept of XML documents. These documents give us a way to communicate complex data in plain text. This plain text works well with the Internet, because HTTP is a plain-text protocol. In addition, many firewalls are programmed to let HTTP through removing a huge hurdle to acceptance.

Web services requests are formatted in a dialect of XML called Simple Object Access Protocol (SOAP). This format enables one programmer to create an XML document and ship it to another computer for execution.

Humans are also able to find out what Web sites are available to them by using their eyes, their voices, and their ears. Programs, on the other hand, are not as flexible. They need a way of finding out what services are available to them, and they can do this by using a Registry that has been created using the Universal Description, Discovery, and Integration (UDDI) format.

These registries form a universal repository of all the services companies, governments, and individuals are willing to allow your program to use, either free, or for a fee.

Other uses for the UDDI are the creation of a private repository. A private repository provides a place for a closed group to find out about Web services that are available inside the company or organization itself.

Humans are also able to connect to Web sites using simple URLs. Programs need more security and also more details when connecting to a Web service. What commands are legal to send? What protocols (HTTP, FTP, JMS, and so on) options does my program have? (With the human Web, the answer is normally HTTP.) Another XML document, the Web service Description Language (WSDL) document provides this information. Figure 26.10 shows how Web services can use the same layers as human Web sites use.

Figure 26.10. Web services are Web sites designed to be used by other programs.

graphics/26fig10.gif

Notice that both the client and the server look like ordinary Web application components to the other layers in the model. Figure 26.11 shows the relationship between each of the three main components of the Web services architecture.

Figure 26.11. Web services send SOAP messages to each other after communication is established.

graphics/26fig11.gif

If the WSDL is already in the possession of the client, no call to the UDDI Registry needs to take place.

The Web services architecture fits into the MVC architecture with the exception that there is not always a View layer present. In some ways, the SOAP messages take the place of the View layer, but it would be a stretch to call them the View. The other layers are in play, however, as shown in Figure 26.12.

Figure 26.12. Web services can also be represented by the MVC architecture.

graphics/26fig12.gif

The diagram shows simple Java Classes as the implementation as Java classes. In reality, these classes could be servlets or EJBs. In fact, the Web services can be written in any language that can handle the reading and writing of text because XML is a text-based language.


       
    Top
     



    Java 2 Primer Plus
    Java 2 Primer Plus
    ISBN: 0672324156
    EAN: 2147483647
    Year: 2001
    Pages: 332

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net