Introducing Web Services


The two main protocols in the ATL Server implementation of Web services are Simple Object Access Protocol (SOAP) and Web Services Description Language (WSDL). SOAP is the protocol for a Web service message, and WSDL is for defining the interface for a service being called.

In this section you ll also look at Universal Description, Discovery, and Integration (UDDI), a publishing service that allows developers to publish their Web services so that other developers may discover and use them. In addition, UDDI allows developers looking for Web services to find and consume those that they have access to.

For more information on SOAP and WSDL, please visit the following Web pages on the World Wide Web Consortium s (W3C s) site:

  • Simple Object Access Protocol (SOAP): http://www.w3.org/TR/SOAP/

  • Web Services Description Language (WSDL): http://www.w3.org/TR/WSDL.html

  • XML Schema Part 0: Primer: http://www.w3.org/TR/xmlschema-0/

  • XML Schema Part 1: Structures: http://www.w3.org/TR/xmlschema-1/

  • XML Schema Part 2: Datatypes: http://www.w3.org/TR/xmlschema-2/

SOAP

SOAP is a protocol for the exchange of information in a distributed environment, which is achieved by the exchange of SOAP messages. You ll see some examples of SOAP messages later in this section.

For many C++ developers, it s probably convenient to consider SOAP as a style of remote procedure call (RPC) using HTTP as the transport and XML as the data format or packaging. Although this definition is an oversimplification, it should provide a good sense of context. It s important to note, however, that neither SOAP nor the ATL Server SOAP support is limited to HTTP as the transport mechanism. Later on, you ll see how users can plug in their own transport mechanisms into the ATL Server SOAP support.

A SOAP message is an XML document with predefined elements that may have user -defined data as subelements. The basic format of a SOAP message as described in section 4 of the SOAP specification is as follows :

 <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">    <SOAP:Header>      <!- user data -->    </SOAP:Header>    <SOAP:Body>      <!- user data -->    </SOAP:Body>  </SOAP:Envelope> 

The Header element of the SOAP message is optional. The Envelope and Body elements are required in the SOAP message. You can find a full description of the SOAP message format in section 4 of the SOAP specification. Here s an example of a simple SOAP message:

 <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">    <SOAP:Body>      <m:HelloWorld xmlns:m="Some-URI">      <inputString>StringValue</inputString>      </m:HelloWorld>    </SOAP:Body>  </SOAP:Envelope> 

Notice that the optional Header element has been omitted. The user data under the Body element is one possible encoding of a Hello World SOAP message. When viewed as an RPC message, the element HelloWorld is a wrapper element under Body that denotes the function name . inputString is a parameter to the function HelloWorld and has the value StringValue .

With that, let s continue on to the other major protocol in ATL Server Web services: WSDL.

WSDL

WSDL is an XML format for describing network services as a series of endpoints containing either document-oriented or procedure-oriented information. WSDL isn t specific to SOAP, but it has a predefined syntax for describing SOAP messages. For those familiar with COM, it may be convenient to think of WSDL as a Web service version of Interface Definition Language (IDL). Again, this is an oversimplification that should help provide some context.

A WSDL document is an XML document, and it uses XML Schemas to describe the format of the messages. (Extensible Schema Definition, or XSD, is described in the specifications you can find at the Web addresses we presented at the start of this section.) Listing 10-1 presents an example of a simple WSDL document.

Listing 10.1: A Simple WSDL Document
start example
 <?xml version="1.0"?>  <!-- ATL Server generated Web Service Description -->  <definitions    xmlns:s="http://www.w3.org/2001/XMLSchema"    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"    xmlns:s0="http://mynamespace"    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"    xmlns:atls="http://tempuri.org/vc/atl/server/"    targetNamespace="http://mynamespace"    xmlns="http://schemas.xmlsoap.org/wsdl/"  >    <types>      <s:schema targetNamespace=http://mynamespace   attributeFormDefault="qualified" elementFormDefault="qualified">        <s:simpleType name="MyEnumeration">          <s:restriction base="s:string">            <s:enumeration value="Value1"/>            <s:enumeration value="Value2"/>            <s:enumeration value="Value3"/>          </s:restriction>        </s:simpleType>        <s:complexType name="MyStruct">          <s:sequence>            <s:element name="EnumValue" type="s0:MyEnumeration"/>            <s:element name="UIntValue" type="s:unsignedInt"/>          </s:sequence>        </s:complexType>      </s:schema>    </types>    <message name="MyMethodIn">      <part name="Parameter1" type="s0:MyStruct"/>    </message>    <message name="MyMethodOut">      <part name="return" type="s0:MyStruct"/>    </message>    <portType name="MyServiceSoap">      <operation name="MyMethod">        <input message="s0:MyMethodIn"/>        <output message="s0:MyMethodOut"/>      </operation>    </portType>    <binding name="MyServiceSoap" type="s0:MyServiceSoap">      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>      <operation name="MyMethod">        <soap:operation soapAction="#MyMethod" style="rpc"/>        <input>          <soap:body use="encoded" namespace="http://mynamespace"  encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>        </input>        <output>          <soap:body use="encoded" namespace="http://mynamespace"  encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>        </output>      </operation>    </binding>    <service name="MyService">      <port name="MyServiceSoap" binding="s0:MyServiceSoap">        <soap:address location="http://localhost/MyService.dll?Handler=MyService"/>      </port>    </service>  </definitions> 
end example
 

All WSDL documents begin with a definitions tag, which may also contain XML namespace declarations. The definitions tag is followed by the types tag, which in turn may contain schema tags, which contain XSD type definitions. In Listing 10-1, the schema element contains a simpleType element and a complexType element. The simpleType element in Listing 10-1 is used to define an enumeration named MyEnumeration , with the values Value1 , Value2 , and Value3 . You may also use the simpleType element to extend or restrict other primitive types (e.g., to restrict the range of an unsignedInt ). The complexType element in Listing 10-1 is used to define a struct named MyStruct , with the field EnumValue , which is of type MyEnumeration , and UIntValue , which is of type unsignedInt . You may also use the complexType element to define arrays, SOAP messages, and other types and elements. The types section is followed by a series of message elements, which are used to define the contents of a SOAP message. The message elements contain message part elements, which reference XSD types. The message elements are followed by one or more portType elements, which compose the individual messages into operations, which form a complete SOAP interaction (request/response). The portType element is in turn followed by a binding element, which references a portType element and its operations to bind the operations to specific SOAP protocols, namespaces, encoding styles, and so on. The final element is the service element, which references a binding element and provides a specific location URL at which the service can be invoked.

This is a very high-level view of WSDL. Listing 10-1 is an example of a WSDL document that is produced by the default configuration and settings of ATL Server Web services. A WSDL document will vary depending on the type of messages that are being passed, the encoding style, the transport mechanism, and other factors. WSDL provides an extensibility method that allows for custom elements to be inserted into WSDL documents. For more details on WSDL, consult the specifications noted previously.




ATL Server. High Performance C++ on. NET
Observing the User Experience: A Practitioners Guide to User Research
ISBN: B006Z372QQ
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net