Showing posts with label Introduction to web services. Show all posts
Showing posts with label Introduction to web services. Show all posts

Saturday, 5 November 2016

The XML schema document

Schemas are more powerful when validating an XML document because of their ability to clarify data types stored within the XML document. Because schemas can more clearly define the types of data that are to be contained in an XML document, they allow for a closer check on the accuracy of XML documents. Following example  illustrates an XML schema for a sample purchase order.

<?xml version="1.0" encoding="UTF-8"?>
 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:PO="http://www.plastics_supply.com/PurchaseOrder" targetNamespace="http://www.plastics_supply.com/PurchaseOrder">
<!-- Purchase Order schema -->
 <xsd:element name="PurchaseOrder" type="PO:PurchaseOrderType"/>
<xsd:complexType name="PurchaseOrderType"> 
<xsd:all> <xsd:element name="ShippingInformation" type="PO:Customer" minOccurs="1" maxOccurs="1"/>
<xsd:element name="BillingInformation" type="PO:Customer" minOccurs="1" maxOccurs="1"/> <xsd:element name="Order" type="PO:OrderType" minOccurs="1" maxOccurs="1"/> </xsd:all> </xsd:complexType>

<xsd:complexType name="Customer">
<xsd:sequence> <xsd:element name="Name" minOccurs="1" maxOccurs="1"> <xsd:simpleType> <xsd:restriction base="xsd:string"/> </xsd:simpleType> </xsd:element> <xsd:element name="Address" type="PO:AddressType" minOccurs= "1" maxOccurs="1"/> <xsd:choice> <xsd:element name="BillingDate" type="xsd:date"/>
<xsd:element name="ShippingDate" type="xsd:date"/>
 </xsd:choice>
 </xsd:sequence>
 </xsd:complexType>
<xsd:complexType name="AddressType"> 
<xsd:sequence>
 <xsd:element name="Street" type="xsd:string"/>
 <xsd:element name="City" type="xsd:string"/> 
<xsd:element name="State" type="xsd:string"/> 
<xsd:element name="PostalCode" type="xsd:decimal"/> <xsd:sequence> </xsd:complexType>
<xsd:complexType name="OrderType">
 <xsd:sequence> <xsd:element name="Product" type="PO:ProductType" minOccurs= "1" maxOccurs="unbounded"/>
 </xsd:sequence> 
<xsd:attribute name="Total"> <xsd:simpleType> <xsd:restriction base="xsd:decimal"> <xsd:fractionDigits value="2"/> </xsd:restriction> </xsd:simpleType> </xsd:attribute> <xsd:attribute name="ItemsSold" type="xsd:positiveInteger"/> </xsd:complexType>
<xsd:complexType name="ProductType">
 <xsd:attribute name="Name" type="xsd:string"/> 
<xsd:attribute name="Price"> <xsd:simpleType>
 <xsd:restriction base="xsd:decimal"> 
<xsd:fractionDigits value="2"/> </xsd:restriction> 
</xsd:simpleType> </xsd:attribute> 
<xsd:attribute name="Quantity" type="xsd:positiveInteger"/>
 </xsd:complexType>

It depicts a purchase order for various items. This document allows a customer to receive the shipment of the goods at the customer’s manufacturing plant and billing information to be sent to the customer’s headquarters. This document also contains specific information about the products ordered, such as how much each product cost, how many were ordered, and so on. The root element of an XML schema document, such as the purchase order schema, is always the schema element. Nested within the schema element are element and type declarations. For instance, the purchase order schema consists of a schema element and a variety of sub-elements, most notably element complexType and simpleType that determine the appearance of elements and their content in instance documents. These components are explained in the following sections. The schema element assigns the XML schema namespace ("http://www.w3.org/ 2001/XMLSchema") as the default namespace. This schema is the standard schema namespace defined by the XML schema specification and all XML schema elements must belong to this namespace. The schema element also defines the targetNamespace attribute, which declares the XML namespace of all new types explicitly created within this schema. The schema element is shown to assign the prefix PO to the targetNamespace attribute. By assigning a target namespace for a schema, we indicate that an XML document whose elements are declared as belonging to the schema’s namespace should be validated against the XML schema. Therefore, the PO targetNamespace can be used within document instances so that they can conform to the purchase order schema. As the purpose of a schema is to define a class of XML documents, the term instance document is often used to describe an XML document that conforms to a particular schema.

XML Document Structure, Introduction to Web Services

XML(Extensible Markup Language) 
XML is an extensible markup language used for the description and delivery of marked-up electronic text over the Web. Two important characteristics of XML distinguish it from other markup languages: its document type concept and its portability. An important aspect of XML is its notion of a document type. XML documents are regarded as having types. XML’s constituent parts and their structure formally define the type of a document. Another basic design feature of XML is to ensure that documents are portable between different computing environments. All XML documents, whatever language or writing system they employ, use the same underlying character encoding scheme. This encoding is defined by the international standard Unicode, which is a standard encoding system that supports characters of diverse natural languages. An XML document is composed of named containers and their contained data values. Typically, these containers are represented as declarations, elements, and attributes. A declaration declares the version of XML used to define the document. The technical term used in XML for a textual unit, viewed as a structural component, is element. Element containers may be defined to hold data, other elements, both data and other elements, or nothing at all. An XML document is also known as an instance or XML document instance. This signifies the fact that an XML document instance represents one possible set of data for a particular markup language. The example in Listing 3.1 typifies an XML document instance. This example shows billing information associated with a purchase order issued by plastics manufacturer. We assume that this company has built a business based on providing “specialty” and custom-fabricated plastics components on a spot and contract basis.

Example of an XML document instance
<?xml version="1.0" encoding="UTF-8"?>
 <BillingInformation> 
<Name> Right Plastic Products </Name> 
<BillingDate> 2002-09-15 </BillingDate> 
<Address> 
<Street> 158 Edward st. </Street> 
<City> Brisbane </City>
 <State> QLD </State>
 <PostalCode> 4000 </PostalCode>
 </Address>
 </BillingInformation>


Tuesday, 11 October 2016

Introduction to web services


What are Web Services?
Web services are an emerging technology that enables disparate applications running on different machines to exchange data and integrate with one another without requiring additional, proprietary third-party software or hardware.

Function of Web services
Web services are self-describing and self-contained network-available modules that perform concrete business functions and are deployed easily because they are based on common industry standards and existing technology, such as XML and HTTP.

Advantages of Web Services
·        Applications that rely on the Web services paradigm can exchange data regardless of the language, platform, or internal protocols they use.
·        They reduce application interface costs.
·        Provide a universal mechanism for integrating business processes within an enterprise and, ultimately, among multiple organizations.

Loosely couple
Services are most often built in a way that is independent of the context in which they are used. This means that the service provider and the consumers are loosely coupled. At the middleware level, the concept of loose coupling requires that the “service-oriented” approach be independent of specific technologies or operating systems.

Service providers
Organizations that provide the service implementations, supply their service descriptions, and provide related technical and business support
Service clients
End-user organizations that use some service
Service aggregators

Organizations that consolidate multiple services into a new, single orchestrated service offering what is commonly known as a business process.