This article has been excerpted from book "The Complete Visual C# Programmer's Guide" from the Authors of C# Corner.
This section reviews XML-based protocols. The information we present here is bundled from official documents. It is important to understand which component fits where. Please refer to the World Wide Web Consortium (W3C) XML Protocol Comparisons Web page (http://www.w3.org/2000/03/29-XML-protocol-matrix/) to compare and contrast a variety of XML protocols. Also note that the XML Schema Definition Tool (Xsd.exe) will help you if you want to use the produced XML files extensively, because it can output XML schema or CLR classes from XDR (XML-Data-Reduced), XML, and XSD (XML Schema Definition) files or from classes in a runtime assembly. Only XML-based protocols in which Microsoft participated are discussed here.
Developers will need a way to discover Web services. Discovery of Web Services (DISCO) provides a way to discover and retrieve WSDL descriptions of services on remote machines. Using the discovery document format (which is also an XML grammar), one can send a discovery document to a remote server and, if any SOAP-enabled services (i.e., Web services) exist, receive back a WSDL description of the services provided. In many cases, developers will not know the URLs of the services. Universal Description, Discovery, and Integration (UDDI) specifies a mechanism whereby Web service providers advertise the existence of their Web services and Web service consumers locate Web services of interest. UDDI is a specification for distributed Webbased information registries of Web services. UDDI is also a publicly accessible set of implementations of the specification that allows businesses to register information about the Web services they offer so that other businesses can find them. UDDI registries are used to promote and discover distributed Web services. The Web Services Discovery Tool (Disco.exe) helps you discover the URLs of Web services located on a Web server. You can also save documents related to each Web service locally. Listing 23.28 shows a sample DISCO document from W3C.
Listing 23.28: A DISCO Document
<-- elements from other namespaces -->
<scl:contractRef ref='my2.sdl' docRef='my.htm'>
<schema:schemaRef ref='my1.xsd' targetNamespace='http://my.org/my1.xsd'/>
UDDI is a building block that enables businesses to quickly, easily, and dynamically find and transact business with one another using their preferred applications. UDDI is designed to provide a searchable directory of businesses and their Web services. A sample UDDI document from W3C appears in Listing 23.29.
Listing 23.29: An UDDI Document
<element ref="discoveryURLs" minOccurs="0" maxOccurs="1"/>
<element ref="description" minOccurs="0" maxOccurs="*"/>
<element ref="contacts" minOccurs="0" maxOccurs="1"/>
<element ref="businessServices" minOccurs="0" maxOccurs="1"/>
<element ref="identifierBag" minOccurs="0" maxOccurs="1"/>
<element ref="categoryBag" minOccurs="0" maxOccurs="1"/>
<attribute name="businessKey" minOccurs="1" type="string"/>
<attribute name="operator" type="string"/>
<attribute name="authorizedName" type="string"/>
Given a Web service, it would be nice to have a standard way to document what messages the Web service accepts and generates-that is, to document the Web service contract. A standard language makes it easy for developers and developer tools to create and interpret contracts. The Web Services Description Language (WSDL) is an XML-based contract language jointly developed by Microsoft and IBM. The Web services contract written using WSDL is an XML document that defines the inputs and outputs of a Web service, including the XML schemas that should be used to create the input and output documents. Each WSDL document contains both an abstract definition of the service and how the service binds to a particular network implementation and data format bindings.
Over the years Microsoft and IBM have proposed several contract languages: Service Description Language (SDL), Service Contract Language (SCL), and Network Accessible Services Specification Language (NASSL). All these are superceded by WSDL. WDSL is a new specification to describe networked XML-based services. It provides a simple way for service providers to describe the basic format of requests to their systems regardless of the underlying protocol (such as SOAP or XML) or encoding (such as Multipurpose Internet Messaging Extensions). WSDL is a key part of the effort of the UDDI initiative to provide directories and descriptions of such online services for electronic business. You can use the Web Services Description Language Tool (Wsdl.exe) to generate WSDL files for ASP.NET Web services-in other words, usable codes from WSDL contract files, XSD schemas, and .discomap discovery documents. Listing 23.30 shows an example of a WSDL document from W3C.
Listing 23.30: A WSDL Document
<element name="tickerSymbol" type="string"/>
<element name="price" type="float"/>
<part name="body" element="xsd1:TradePrice"/>
<part name="body" element="xsd1:TradePriceResult"/>
<binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">
<documentation>My first service</documentation>
<port name="StockQuotePort" binding="tns:StockQuoteBinding">
Simple Object Access Protocol (SOAP) is a lightweight, XML-based protocol for exchange of information in a decentralized, distributed environment. It consists of three parts: an envelope that defines a framework for describing what is in a message and how to process it, a set of encoding rules for expressing instances of application-defined data types, and a convention for representing remote procedure calls and responses. SOAP can potentially be used in combination with a variety of other protocols; however, the only bindings defined in the SOAP specification describe how to use SOAP in combination with HTTP and HTTP Extension Framework. The Soapsuds tool (Soapsuds.exe) creates XML schemas describing services exposed so you can compile client applications that communicate with Web services using a technique called remoting. A sample SOAP document from W3C appears in Listing 23.31.
Listing 23.31: A SOAP Document
<title>My Life and Work</title>
<street>Martin Luther King Rd</street>
Official information about the BizTalk protocol is available at http://www.biztalk.org/. Microsoft has also put a back-office product called BizTalk server on the market to make it easier to develop and deploy BizTalk-based business-to-business, business-to-customer, customer-to-business, and customer-to-customer applications between internal and external commodity merchandisers.
The Microsoft BizTalk Framework is an XML framework for application integration and electronic commerce. It includes a design framework for implementing an XML schema and a set of XML tags used in messages sent between applications. Microsoft, other software companies, and industry standards groups can use the BizTalk Framework to create XML schemas in a consistent manner. The BizTalk Framework itself is not a standard: XML is the standard. The goal of the BizTalk Framework is to accelerate the rapid adoption of XML. BizTalk Framework schemas, which are business documents and messages expressed in XML, can be registered and stored on the BizTalk.org Web site.
Any individual or organization can download the framework and use it to create and submit an XML schema to the Web site. As long as the schema passes a verification test, it is considered a valid BizTalk Framework schema. Individuals and organizations can freely use XML schemas from the BizTalk.org Web site in their applications for as long as the schema is published for public use. The BizTalk Framework schema design has been submitted to W3C for adoption as an XML schema standard. A sample BizTalk document from W3C appears in Listing 23.32.
Listing 23.32: A BizTalk Document
Hope this article would have helped you in understanding XML-Based Protocols. See other articles on the website on .NET and C#.
| ||The Complete Visual C# Programmer's Guide covers most of the major components that make up C# and the .net environment. The book is geared toward the intermediate programmer, but contains enough material to satisfy the advanced developer.|