The Web services architecture is based on the following basic components:
The following sections discuss these components in detail.
XML is the markup language used to describe data in a document. Because XML is a text based and platform-independent language, it is used as the standard format for transferring data over a network by using Web services.
You learned about XML schemas in "Basics of XML." An XML schema documentconsists of elements, attributes, and data types that can be included in an XML document. To allow you to create XML schemas, the World Wide Web Consortium (W3C) published the XML schema recommendation in 2001.
This XML schema recommendation was called W3C XML schema. To implement XML schema recommendations, Microsoft developed a new language known as XML Schema Definition (XSD). XSD forms a part of the XML schema recommendation.
XSD is a schema language that defines the structure of an XML document. In addition, XSD uses the XML syntax to define the data in the XML document. To do this, XSD provides you with a set of predefined tags. We will discuss these tags and other components of an XSD document in the following sections.
Components of an XSD Document
An XSD document consists of the declaration statement and the elements that define the data in an XSD document. These components of an XSD document are discussed in detail in the following sections.
The Declaration Statement
In the beginning of the XSD document, you need to include the XML declaration statement as in any other XML document. The following code shows the XML declaration statement:<?xml version = "1.0" ?>
The schema Element
Similar to an XML document, the content of the XSD document is stored in the form of elements. An XSD document consists of the schema element, which further comprises elements containing the data. This data includes the data types and the elements that define the data in the XML document. In addition, the schema element contains information about the namespace that is associated with the XML document. To define the namespace, the schema element uses the xmlns keyword.
In the preceding example, we used a hypothetical site, http://www.exampleuri.com/, which hosts the Credit_Details Web service.
The syntax of the XSD document is as shown:<?xml version = "1.0" ?><xsd:schema xmlns:xsd="http://www.wisdomjobs.com/e-university"><elements></xsd:schema>
The element Element
element is used to define the structure of the XML document and has two attributes: name and type. The name attribute specifies the name of the element, and the type attribute specifies the data type of the element. The syntax for element is as follows:<xsd:element name=<name> type=<data type>><data></xsd:element>
Having discussed the components of an XSD document, you will learn to create a sample XSD document in the following section.
Creating a Sample XSD Document
An XSD document needs to be associated with an XML document. The code for the XML document is as shown:
Adding Code to the XSD Document
Now you can create an XSD document for the preceding XML document. To create an XSD document, you can use the available tools. These tools help you to create XSD documents for existing XML documents. The XSD document for the preceding XML document is as follows:
Save the preceding file with the name StudData.xsd.
The preceding code is an XSD document for the corresponding XML file. The following section discusses the structure of that XSD document.
Structure of the Sample XSD Document
As discussed earlier, an XSD document consists of a declaration statement followed by the schema element that specifies the schema recommendation to be included in the document. Then an element with the name Student_Details is declared with a user-defined data type: studdata. studdata is a complex data type. You can create simple or complex data types to define the type of data that an element can store. The simple or complex data types are discussed in the following list:
Therefore, to declare the studdata data type as complex, you use the complexType attribute. Next, the sequence element is used to define the sequence of child elements within the Student_Details element. Inside the sequence element, another element with the name Student is declared with a user-defined data type of Stud. Because this data type has a user-defined name, it is called a named data type.
You can create data types without specifying a name for them. For example, the previous code can also be written as follows:
As you can see in the preceding code, the Student element has a maxOccurs attribute assigned to it. This attribute specifies the maximum number of times that the associated element can occur in the document. Because the Student.xml document can contain any number of entries for students, we have assigned the value for the maxOccurs attribute as unbounded.
Then, within the Stud data type, the child elements for the Student element are defined. These child elements include Name, Address, City, State, and Zip. In addition, you can specify the data type for these child elements in the Stud data type.
The Student element in the XML document has two attributes: ID and Form. Therefore, you need to declare these attributes in the XSD document. You can declare attributes by using the attribute element. This element specifies the name and data type of the attribute. In addition, you can assign a default value to the attribute by using the default attribute.
The standard data types that you can include in an XML document are string, float, decimal, date, and so on.
If you need to assign a fixed value to an attribute, you can use the fixed attribute. A fixed value is a value that you cannot change in the XML document.
As you can see in the XSD document, the attribute declaration statement also includes the use attribute. The value that is assigned to this attribute is required. This implies that you cannot leave the associated attribute blank. If no value is assigned to this attribute, an error is generated when the XML document is validated.
Finally, you need to provide closing tags for the elements sequence, complexType, and schema.
Role of XSD in XML Web Services
Consider a scenario in which two organizations decide to exchange their data by using Web services. As discussed earlier, the standard used to exchange data over the network is XML. Therefore, the two organizations need to mutually decide on the standards and structure of the XML documents that are transferred. This enables the two organizations to easily create and interpret the XML documents. The standards, elements, attributes, values, data types, and structure of the XML documents are defined in the XSD document. This implies that the two organizations mutually agree on the XSD document to enable transfer of data across organizations.
Another important component of Web services is SOAP, which is used to define a standard way of packaging a message for interpretability. The reason for choosing SOAP as the standard protocol is that it is both a simple and a light mechanism for transferring data. SOAP uses XML to transfer data; therefore, it is a light protocol. In addition, the sending and receiving applications can easily interpret the data.
To transfer messages by using SOAP, the message in any form is packaged as a SOAP package, which is a well-formed XML document. The SOAP package is then transferred over protocols, such as FTP or HTTP.
The SOAP specification defines the standards or rules used to transfer SOAP messages over the network by using any of the standard network transfer protocols. However, SOAP is not a network or a transfer protocol. In addition, the syntax for creating the XML document is defined in the specification. You will learn about SOAP packages in detail in "Introduction to SOAP."
As discussed earlier, you need to register the Web service with the service registry. The description language used to define a Web service and its interface is called WSDL. WSDL is an XML-based language that defines a Web service. It is used to provide information about a Web service to the requesting applications. This information includes a description of the Web service, a location of the Web service, binding information, a method for accessing a Web service, and a way to exchange data by using a Web service.
Consider a scenario in which a Web service client application requests a Web service to validate the user and password information that a user enters. The Web service includes one or more Web methods that the Web service client application needs to access. The information about the mechanism to access the Web service is described using WSDL.
In addition, when a request for the Web service is made, the user needs to pass the name and password as parameters to the Web service call statement. The information about these parameters is also specified using WSDL in a WSDL document.
You will learn about WSDL in detail in "Introduction to WSDL."
A Web service is registered with a group of Web-based registries called UDDI Business Registries. UDDI registries are an industry standard in which organizations, such as Microsoft and IBM, register their Web services. The mechanism used to register a Web service is called UDDI. You will learn in detail about UDDI in "Introduction to UDDI."
A UDDI directory is a Web site that provides a listing and references for all Web services. Therefore, a UDDI directory is like yellow pages for Web services. To provide information about a Web service, UDDI creates a pointer to all Web services. This pointer points to the WSDL document for the respective Web services. When a user searches for information about a Web service, UDDI returns the information stored in the WSDL document. The requesting application can then use the Web service if required. The following list discusses the benefits of registering a Web service with the UDDI directory:
XML Related Interview Questions
|Soap Tool Interview Questions||HTML Interview Questions|
|PHP Interview Questions||ASP.NET Interview Questions|
|PHP5 Interview Questions||Java Interview Questions|
|CSS Interview Questions||XSLT Interview Questions|
|Java XML Interview Questions||XMLHttpRequest (XHR) Interview Questions|
|ebXML Interview Questions||XML DOM Interview Questions|
|XML-RPC Interview Questions||XSD Interview Questions|
|Soap Web Services Interview Questions||XSL Interview Questions|
|Xml Publisher Interview Questions|
Basics Of Xml
Basics Of Web Services
Introduction To Soap
Introduction To Uddi
Introduction To Wsdl
Creating A Web Service Using The Microsoft Soap Toolkit
Building Web Applications On The .net Platform
Creating An Asp.net Web Service
Creating A Web Service From An Interface
Introduction To The Atl Server
Creating A Web Service Using The Atl Server Library
Design And Creation Of The Knowledge Share Web Service
Introduction To Java Xml Technologies
Developing Java Web Services
Design And Creation Of A Web Service Using The Ibm Toolkit
Introduction To Mobile Applications
Creating A Mobile Application That Consumes A Web Service
Web Services Development With Jdeveloper
Creating Web Services Using Perl
Integration Of Xml Web Services With The Office Xp And Sql
Server 2000 Toolkits
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.