Off late, Web services are one the buzz word most of the software people uses. In this article let us try to understand the basics of Web Service. Let us start off by asking our self “What is a Web Service?”
What is a Web Service?
Web Service is software components that expose a service over the web.
- It allows applications to share data and functionality.
- It can be called across platforms and operating systems regardless of the programming language used by applications.
- You can invoke this application programmatically over the Web using SOAP protocol.
In .Net a web service is an ASP.NET application with <.asmx> extension. The basic elements of web services are SOAP (XML + HTTP), UDDI and DISCO.
UDDI stands for Universal Description Discovery and Integration. UDDI defines a way to publish and discover information about web services.
UDDI is like a registry rather than like a repository. A registry contains only reference information. For example, the windows registry contains the name of COM objects and not the entire code. When we invoke a COM object, the system finds the registry entries and then it redirects execution to the actual binary part for that COM object. UDDI works the same way!
Using Microsoft UDDI SDK, web services can be registered for public use at http://www.uddi.org. VS.NET provides a web service with the option to register and publish itself from the IDE.
After choosing a web service through UDDI the next step is to access its discovery. Discovery is the process of locating and examining XML Web Service descriptions. Through this process a client understands that web service capabilities. Programmatic discovery is enabled through a “.disco” file, which is an XML document that contains links to other discovery documents, XSD schemas and service descriptions (WSDL).
A discovery document is automatically generated for an XML Web service when the web service is accessed using a URL with “?DISCO” in the query string.
For instance, if the URL to an XML Web service is http://www.vadivel.com/Calc.asmx, then a discovery document is automatically generated with a URL of http://www.vadivel.com/Calc.asmx?DISCO.
SOAP stands for Simple Object Access Protocol. SOAP is an XML based lightweight protocol, which allows software components and applications communicate, mostly using HTTP. SOAP sits on top of the HTTP protocol. It is message-based and nothing but an XML document with a pre-defined format.
The following features make SOAP the most preferred way of communication over the web:
- Platform independency
- Language independency
- XML based
- Based on W3C standard
Every SOAP message has an envelope, a header (optional) and Body (SOAP message in XML format).
- The envelope defines the content of the message.
- The header (optional) contains header information.
- The body contains call and response information.
Before the advent of web service and .Net, technologies like DCOM/CORBA etc., were used for network communication. But those were vendor specific and interoperability between them was quite complex.
Remote procedure calls (RPC) was used for communication between technologies like DCOM and CORBA, but HTTP was not designed for this. Most of the corporate networks use proxy/firewalls that allow only HTTP requests (Firewalls/proxy servers would normally block RPC). Web sites too allow mostly HTTP traffic through port 80.
All Internet browsers and servers support HTTP. So HTTP is generally a better way to communicate between applications. That’s where SOAP comes into play.
Web Service Description Language (WSDL)
Let’s say we have created a web service. How does the consumer know how to use it? Like, which method to invoke and what parameters to pass?
There are many possible ways we can think of to accomplish this task.
- May be we can write a document that provides this information or
- We can verbally explain the information to the user.
These informal approaches have at least one serious problem. When developer sits down to build a client for your web service, their development tool cannot offer them any help because that tool has no idea about the web service’s functions and parameters. The solution is to provide a formal description in a machine-readable format.
The WSDL is an XML-based grammar for describing the web services; it’s a function, parameters and return values. Being XML-based, WSDL is both machine and human readable.
In this article I have explained about the basic elements of Web Services. In the next article we would look deep in to the topic “Web Services in .NET”. Feel free to ping me at firstname.lastname@example.org for any further discussion about this. On the other hand you can catch me @ http://vadivel.thinkingms.com. Happy programming!