Web Services#
What Is The Web Services?#
-
Different books and different organizations provide different definitions to Web Services. Some of them are listed here.
-
A web service is any piece of software that makes itself available over the internet and uses a standardized XML messaging system. XML is used to encode all communications to a web service. For example, a client invokes a web service by sending an XML message, then waits for a corresponding XML response. As all communication is in XML, web services are not tied to any one operating system or programming language - Java can talk with Perl; Windows applications can talk with Unix applications.
-
Web services are self-contained, modular, distributed, dynamic applications that can be described, published, located, or invoked over the network to create products, processes, and supply chains. These applications can be local, distributed, or web-based. Web services are built on top of open standards such as TCP/IP, HTTP, Java, HTML, and XML.
-
Web services are XML-based information exchange systems that use the Internet for direct application-to-application interaction. These systems can include programs, objects, messages, or documents.
-
A web service is a collection of open protocols and standards used for exchanging data between applications or systems. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer. This interoperability (e.g., between Java and Python, or Windows and Linux applications) is due to the use of open standards.
-
-
To summarize, a complete web service is, therefore, any service that:
- Is available over the Internet or private (intranet) networks
- Uses a standardized XML messaging system
- Is not tied to any one operating system or programming language
- Is self-describing via a common XML grammar
- Is discoverable via a simple find mechanism
Components of Web Services#
- The basic web services platform is XML + HTTP. All the standard web services work using the following components
- SOAP (Simple Object Access Protocol)
- UDDI (Universal Description, Discovery and Integration)
- WSDL (Web Services Description Language)
SOAP#
-
Simple Object Access Protocol (SOAP)
is a lightweight XML-based protocol that is used for the exchange of information in decentralized, distributed application environments. You can transmit SOAP messages in any way that the applications require, as long as both the client and the server use the same method. The current specification describes only a single transport protocol binding, which is HTTP. -
SOAP
perfectly fits into the world of Internet applications and promises to improve Internet inter-operability for application services in the future. In essence, SOAP packages method calls into XML strings and delivers them to component instances through HTTP. -
SOAP
XML documents are structured around root elements, child elements with values, and other specifications. First an XML document containing a request (a method to be invoked and the parameters) is sent out. The server responds with a corresponding XML document that contains the results. -
SOAP
is not based on Microsoft technology. It is an open standard drafted by UserLand, Ariba, Commerce One, Compaq, Developmentor, HP, IBM, IONA, Lotus, Microsoft, and SAP. SOAP 1.1 was presented to the W3C in May 2000 as an official Internet standard. Microsoft is one of the greatest advocates of SOAP and has incorporated SOAP as a standard interface in the .NET architecture. -
A SOAP stack, an implementation of the SOAP standard on the client side, is comprised of libraries and classes that offer helper functions. A significant Web service testing challenge is that there are a number of SOAP stack implementations that are not compatible with one another. So although SOAP is intended to be both platform- and technology-independent, it is not. Web services written in .NET are however always compatible with .NET clients—they use the same SOAP stack, or library. When testing a .NET Web service however, you need to confirm if the service is compatible with other SOAP stack implementations, for example Java SOAP stack, to avoid interoperability issues.
-
SOAP client requests are encapsulated within HTTP POST or M-POST packages. The following example is taken from the Internet draft-specification.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
-
The first four lines of code are standard HTTP. POST is the HTTP verb which is required for all HTTP messages. The Content-Type and Content-Length fields are required for all HTTP messages that contain payloads. The content-type text/xml indicates that the payload is an XML message to the server or a firewall capable of scanning application headers.
-
The additional HTTP header SOAPAction is mandatory for HTTP based SOAP messages, and you can use it to indicate the intent of a SOAP HTTP request. The value is a URI that identifies the intent. The content of a SOAPAction header field can be used by servers, for example firewalls, to appropriately filter SOAP request messages in HTTP. An empty string ("") as the header-field value indicates that the intent of the SOAP message is provided by the HTTP Request-URI. No value means that there is no indication on the intent of the message.
-
The XML code is straightforward. The elements Envelope and Body offer a generic payload-packaging mechanism. The element GetLastTradePrice contains an element called symbol, which contains a stock-ticker symbol. The purpose of this request is to get the last trading price of a specific stock, in this case Disney (DIS).
-
The program that sends this message only needs to understand how to frame a request in a SOAP-complient XML message and how to send it through HTTP. In the following example, the program knows how to format a request for a stock price. The HTTP server that receives the message knows that it is a SOAP message because it recognizes the HTTP header SOAPAction. The server then processes the message.
-
SOAP
defines two types of messages,calls
andresponses
, to allow clients to request remote procedures and to allow servers to respond to such a request. The previous example is an example of a call. The following example comes as a response in answer to the call.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
-
The first three lines of code are standard HTTP. The first line indicates a response code to the previous POST request, the second and third line indicate the content type and the fourth line the lenght of the response.
-
XML headers enclose the actual SOAP payloads. The XML element GetLastTradePriceResponse contains a response to the request for a trading price. The child element is Price, which indicates the value that is returned to the request
UDDI#
Universal Description, Discovery, and Integration (UDDI)
specification defines a way to publish and discover information about Web services.-
UDDI
has two functions:- It is a SOAP-based protocol that defines how clients communicate with UDDI registries.
- It is a particular set of global replicated registries.
-
UDDI
includes an XML schema for SOAP messages that defines a set of documents to describe business and services information, a common set of APIs for querying and publishing information to the directories, and an API for replicating directory entries between peer UDDI nodes. -
UDDI registries
:UDDI
manages the discovery of Web services by relying on a distributed registry of businesses and their service descriptions implemented in a common XML format. Before you can publish your business entity and Web service to a public registry, you must first register your business entity with aUDDI registry
. -
UDDI registries
come in two forms: public and private. Both types comply to the same specifications. A private registry enables you to publish and test your internal e-business applications in a secure, private environment. -
A public registry
is a collection of peer directories that contain information about businesses and services. It locates services that are registered at one of its peer nodes and facilitates the discovery of published Web services. Data is replicated at each of the registries on a regular basis. This ensures consistency in service description formats and makes it easy to track changes as they occur. IBM® maintains two public registries called the IBM UDDI Business Registry and the IBM UDDI Test Registry. The IBM UDDI Test Registry allows you to develop your Web service and experience the UDDI registration process without placing your Web service in an official registry. Use the IBM UDDI Test Registry to experiment with UDDI, and to test and validate your Web service. -
A private registry
allows you to publish and test your internal applications in a secure, private environment. -
The UDDI Business Registry acts as a B2B directory linking marketplaces, buyers, and sellers. The information provided in the registry consists of three components: white pages, yellow pages, and green pages. White pages include the business name, contact information, and a text description of the business's services. Yellow pages include industrial categorizations based on standard taxonomies such as NAICS, ISO 3166, and UNSPSC. Green pages include references to specifications for Web services and pointers to various file and URL-based discovery mechanisms. This makes it easy for businesses to integrate across marketplaces. Because it is registered, information is made available across all applications.
-
Businesses populate the registry with descriptions of the services that they support.
UDDI
assigns a unique identifier to each service description and business registration. These become the service and business keys respectively. Search engines, and applications query the registry to discover services.UDDI
servers are a directory of available services and service providers.
WSDL#
WSDL
stands for Web Service Description Language,WSDL
is an XML notation for describing a web service. AWSDL
definition tells a client how to compose a web service request and describes the interface that is provided by the web service provider.- A
WSDL
definition is divided into separate sections that specify the logical interface and the physical details of a web service. The physical details include both endpoint information, such as HTTP port number, and binding information, which specifies how the SOAP payload is represented and which transport is used. WSDL
is an important component for building web applications. It facilitates various applications that are built on multiple languages to interact with each other.WSDL
is used as the combination of SOAP and XML schemas that provide communication between the clients and web services over the internet. To read theWSDL
file, the client program must connect to the Web service and specify the operation required to connect to the Web server.- WSDL Document Elements
Element | Description |
---|---|
Definitions | It is the basic element of the WSDL document that contains the definition of one or more services. |
Types | The Type element is used to give information about the complicated data types used within the WSDL document. |
Message | It contains abstract data that is being used in communication between client and web server. It also defines the data elements for each operation. |
portType | It contains the collection of abstract operation supported by one or more endpoints. |
Port | It is used to define the single endpoint as an address for the binding. |
Services | It is a collection of endpoint networks that specify the port address for the binding. |
Binding | It specifies how operations are implemented by concrete protocols and data format features for operation and messaging. |
- Structure of WSDL Document
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
- We can also add other elements such as extension elements and service elements combined into a single WSDL document with possible definitions of multiple web services.
-
The following are the four major transmissions of the WSDL that support endpoint in the SoapUI tool.
- One Way
- Request and Response
- Solicit response
- Notification
-
One way
: A one-way service can only receive one-way messages. It means that the client can send a request to the server by executing an operation with a single input element.
1 2 3 4 5 6 7 |
|
Request and Response
: The Request and Response service is used to send a request to the server and receive a response from the web server. It has two operation elements. The first input element is followed by another element to send and receive the request and response in the web service.
1 2 3 4 5 6 7 8 |
|
Solicit Response
: A solicit response consists of an operation involving two input elements. The first input element contains a server request for the client, followed by one input element of the client's response back to the server.
1 2 3 4 5 6 7 8 9 |
|
Notification
: A server sends information or message to a client machine. Therefore, a notification consists of an operation that includes an input element to send a notification to the client.
1 2 3 4 5 6 7 |
|
- Example of an
WSDL
file is showed as below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|