Chapter 8 Web Services Objectives Describe the Web services approach to the Service- Oriented Architecture concept Describe the WSDL specification and how it is used to define Web services Describe the Java APIs for programming Web services and give examples of their use Discuss how to expose plain Java objects and EJBs as Web services and deploy Web services in J2EE Describe the UDDI specification and how is used as a Web service discovery mechanism Describe the Java API that can be used to interact with a UDDI registry and give examples of its use Provide detailed step-by-step examples of how to program Web services in Java
Overview The term Web services is used to categorize software applications that are exposed over a network via the use of XML standards and Internet protocols in such a manner that they are highly interoperable with other disparate distributed applications Web services are based on an architectural style called service-oriented architecture (SOA) The concept behind SOA is that different functional units of a business process are exposed via software as services to be consumed over a network By the term service we mean a unit of work done by a service provider to achieve desired results for a service consumer (also commonly referred to as service requester)
Service Oriented Architecture Examples of services in the banking industry might be a loan processing service, an account transaction service to handle withdrawals, deposits, and transfers, or a service that handles processing charges to credit cards Some of the primary goals of SOA are interoperability and loose coupling among interacting software applications, a separation of concerns, and reusability of services SOA focuses on integrating independent business services, regardless of the technology used to implement the services. This way of thinking allows businesses to better align their services with business needs rather than the technology in which their systems are implemented.
Service Oriented Architecture, cont. Most of the design effort in SOA is focused on creating service interfaces that serve as contracts for how the services are to be invoked and respond. A well-defined service interface provides a clear separation from any hardware, operating systems, programming languages, or protocols that may compose the service implementation. Applications are integrated via the service interface, not the service implementation. As a result, the applications are loosely coupled. The benefit of loosely coupled applications lies in their ability to survive evolutionary changes in their structure and implementation. Tightly coupled systems are based on interfaces that are tightly interrelated in function and form, thus making them brittle to any form of change that may be required.
Service Oriented Architecture, cont. In SOA, large business processes are broken down into generic, loosely coupled, functional units (called services) in which each unit performs a different task. These services can then be orchestrated together to form any number of different business processes. Since integration is tied to interfaces and not the implementation, changing a service provider is not hindered by incompatibilities in underlying platforms. If later on the company finds that another service provider has better prices, then the system can easily be repositioned to use that provider. Or the system can be designed to dynamically choose among different service providers based on qualities like price or performance. In SOA, the services become the building blocks to develop complete applications.
Service Oriented Architecture, cont. Service-oriented architectures can be conceptualized as containing three roles (service provider, service broker, and service requester) and three operations (publish, find, and bind). The three operations define the relationships between the three roles. The three roles communicate by sending request messages and processing any response messages. Service Broker Find Publish Service Requester Bind Service Provider
Service Oriented Architecture, cont. Service Provider The service provider develops the service interface and implementation and deploys the service so that it is available to be invoked over a network. The service provider also creates a service description and publishes that service description with one or more service brokers (this is the publish operation). Service Broker The service broker is also commonly called the service registry. The broker accepts requests from service providers to publish information about the services they want to make available. The information published includes the type of the service, a description of the service, and the location where the service can be invoked. The service requester can then query the service broker to find a particular service (this is the find operation).
Service Oriented Architecture, cont. Service Requester The service requester uses the service broker to find services that match some set of criteria. The service requester can then use the service description to connect to the service and invoke it (this is the bind operation). The act of finding a service is also called service discovery. The key to making SOA work is the service description and the interface it describes. The service interface provides a mechanism for decoupling different software functional units (services). The service description provides a mechanism that can be used to dynamically compose the resulting services. The service description is published to the service registry by the service provider, then retrieved by the service requester via the find operation, and then used to dynamically bind to the service to form a business process.
Web Services Web services is one approach to implementing a serviceoriented architecture that uses XML-based data representations and communications protocols to achieve platform independence and thus interoperability. Web services are considered the next evolutionary step in distributed computing beyond technologies like CORBA, DCOM, and J2EE. Web services, despite the name, can and are deployed on all types of networks including local area networks (typically corporate intranets). Web services ease the difficulty of enterprise application integration, particularly between organizations (B2B). They allow business systems to be built quickly by combining Web services built internal to an organization with those of business partners.
Web Services, cont. The four core Web service technologies XML, SOAP, Web Services Description Language (WSDL), and Universal Description, Discovery, and Integration (UDDI). These technologies have unprecedented industry backing. XML (extensible Markup Language) is the basis for SOAP, WSDL, and UDDI. Depending on your definition of Web services, XML is really the foundation for all Web service technologies. Representing data in XML is one of the primary keys to Web service s interoperability. SOAP Web services basically involve the exchange of XML documents or data that is organized into an XML format. SOAP provides a standard routing and packaging format for transmitting that XML data between applications on a network.
Web Services, cont. WSDL (commonly pronounced as whiz-dul ) is the technology that is used to write the service description. WSDL allows an organization to describe the types of XML documents and SOAP messages that must be used to interact with their Web services. A WSDL service description is just an XML document that is conformant to the WSDL schema definition. UDDI A technology that enables service discovery. Before an organization can use a Web service, they must first discover the Web service description. UDDI defines a standard set of operations that can be invoked via SOAP messages, which are used to publish and find Web service descriptions. In other words, UDDI is one approach to creating a service registry.
Web Services, cont. <SOAP> <XML> </XML> </SOAP> Service Broker (UDDI registry) 2) Find Web service Service Requester (Web service client) 3) Download WSDL 4) Invoke Web service <WSDL> </WSDL> <SOAP> <XML> </XML> WSDL document location (could be anywhere on the network; often it is with the Service Provider) <SOAP> <XML> </XML> </SOAP> 1) Publish Web service </SOAP> Service Provider (Web service) Web Services Interaction