Home > Articles > Web Services

  • Print
  • + Share This
This chapter is from the book

Workshop

The Workshop is designed to help you review what you've learned in this hour and to point you ahead to the
material that will be covered in future lessons.

Quiz

  1. How would you declare an array of integers using XSD?

    1. <s:complexType name="ArrayofInt">

         <s:Sequence>
    		   <s:element minOccurs="0" maxOccurs="unbounded"
    		    name="int" type="s:int">
    		  </s:sequence>	  </s:complexType>
    
  2. Where would you look to determine the return type of a method?

    1. Start by looking at the portType for the Service and find output message of the method in question.
      Then, go to the message and look to see the type.

  3. What are the two common attributes of the message element?

    1. name and element

  4. What are the three common ports encountered in WSDL documents?

    1. SOAP, HttpGet, and HttpPost

  5. What element actually contains the type, message, and services elements, that is, the root element?

    1. definitions

Exercises

Work through the following WSDL file and see if you can figure out the name of the service, the number of its
methods, and what each method actually looks like (that is, its name, arguments, and returns).

<?xml version="1.0" encoding="utf-8"?>
<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:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soap=
"http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc=
"http://schemas.xmlsoap.org/soap/encoding/"
xmlns:s0="http://tempuri.org/" targetNamespace=
"http://tempuri.org/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <types> <s:schema attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://tempuri.org/"> <s:element name="Add"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="iNum1" type="s:int" /> <s:element minOccurs="1" maxOccurs="1" name="iNum2" type="s:int" /> </s:sequence> </s:complexType> </s:element> <s:element name="AddResponse"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="AddResult" type="s:int" /> </s:sequence> </s:complexType> </s:element> <s:element name="Subtract"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="iNum1" type="s:int" /> <s:element minOccurs="1" maxOccurs="1" name="iNum2" type="s:int" /> </s:sequence> </s:complexType> </s:element> <s:element name="SubtractResponse"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="SubtractResult" type="s:int" /> </s:sequence> </s:complexType> </s:element> <s:element name="Multipl"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="iNum1" type="s:int" /> <s:element minOccurs="1" maxOccurs="1" name="iNum2" type="s:int" /> </s:sequence> </s:complexType> </s:element> <s:element name="MultiplResponse"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="MultiplResult" type="s:int" /> </s:sequence> </s:complexType> </s:element> <s:element name="Divided"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="iNum1" type="s:int" /> <s:element minOccurs="1" maxOccurs="1" name="iNum2" type="s:int" /> </s:sequence> </s:complexType> </s:element> <s:element name="DividedResponse"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="DividedResult" type="s:int" /> </s:sequence> </s:complexType> </s:element> <s:element name="int" type="s:int" /> </s:schema> </types> <message name="AddSoapIn"> <part name="parameters" element="s0:Add" /> </message> <message name="AddSoapOut"> <part name="parameters" element="s0:AddResponse" /> </message> <message name="SubtractSoapIn"> <part name="parameters" element="s0:Subtract" /> </message> <message name="SubtractSoapOut"> <part name="parameters" element="s0:SubtractResponse" /> </message> <message name="MultiplSoapIn"> <part name="parameters" element="s0:Multipl" /> </message> <message name="MultiplSoapOut"> <part name="parameters" element="s0:MultiplResponse" /> </message> <message name="DividedSoapIn"> <part name="parameters" element="s0:Divided" /> </message> <message name="DividedSoapOut"> <part name="parameters" element="s0:DividedResponse" /> </message> <message name="AddHttpGetIn"> <part name="iNum1" type="s:string" /> <part name="iNum2" type="s:string" /> </message> <message name="AddHttpGetOut"> <part name="Body" element="s0:int" /> </message> <message name="SubtractHttpGetIn"> <part name="iNum1" type="s:string" /> <part name="iNum2" type="s:string" /> </message> <message name="SubtractHttpGetOut"> <part name="Body" element="s0:int" /> </message> <message name="MultiplHttpGetIn"> <part name="iNum1" type="s:string" /> <part name="iNum2" type="s:string" /> </message> <message name="MultiplHttpGetOut"> <part name="Body" element="s0:int" /> </message> <message name="DividedHttpGetIn"> <part name="iNum1" type="s:string" /> <part name="iNum2" type="s:string" /> </message> <message name="DividedHttpGetOut"> <part name="Body" element="s0:int" /> </message> <message name="AddHttpPostIn"> <part name="iNum1" type="s:string" /> <part name="iNum2" type="s:string" /> </message> <message name="AddHttpPostOut"> <part name="Body" element="s0:int" /> </message> <message name="SubtractHttpPostIn"> <part name="iNum1" type="s:string" /> <part name="iNum2" type="s:string" /> </message> <message name="SubtractHttpPostOut"> <part name="Body" element="s0:int" /> </message> <message name="MultiplHttpPostIn"> <part name="iNum1" type="s:string" /> <part name="iNum2" type="s:string" /> </message> <message name="MultiplHttpPostOut"> <part name="Body" element="s0:int" /> </message> <message name="DividedHttpPostIn"> <part name="iNum1" type="s:string" /> <part name="iNum2" type="s:string" /> </message> <message name="DividedHttpPostOut"> <part name="Body" element="s0:int" /> </message> <portType name="Calc1Soap"> <operation name="Add"> <documentation>This function adds to integers</documentation> <input message="s0:AddSoapIn" /> <output message="s0:AddSoapOut" /> </operation> <operation name="Subtract"> <input message="s0:SubtractSoapIn" /> <output message="s0:SubtractSoapOut" /> </operation> <operation name="Multipl"> <input message="s0:MultiplSoapIn" /> <output message="s0:MultiplSoapOut" /> </operation> <operation name="Divided"> <input message="s0:DividedSoapIn" /> <output message="s0:DividedSoapOut" /> </operation> </portType> <portType name="Calc1HttpGet"> <operation name="Add"> <documentation>This function adds to integers</documentation> <input message="s0:AddHttpGetIn" /> <output message="s0:AddHttpGetOut" /> </operation> <operation name="Subtract"> <input message="s0:SubtractHttpGetIn" /> <output message="s0:SubtractHttpGetOut" /> </operation> <operation name="Multipl"> <input message="s0:MultiplHttpGetIn" /> <output message="s0:MultiplHttpGetOut" /> </operation> <operation name="Divided"> <input message="s0:DividedHttpGetIn" /> <output message="s0:DividedHttpGetOut" /> </operation> </portType> <portType name="Calc1HttpPost"> <operation name="Add"> <documentation>This function adds to integers</documentation> <input message="s0:AddHttpPostIn" /> <output message="s0:AddHttpPostOut" /> </operation> <operation name="Subtract"> <input message="s0:SubtractHttpPostIn" /> <output message="s0:SubtractHttpPostOut" /> </operation> <operation name="Multipl"> <input message="s0:MultiplHttpPostIn" /> <output message="s0:MultiplHttpPostOut" /> </operation> <operation name="Divided"> <input message="s0:DividedHttpPostIn" /> <output message="s0:DividedHttpPostOut" /> </operation> </portType> <binding name="Calc1Soap" type="s0:Calc1Soap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> <operation name="Add"> <soap:operation soapAction="http://tempuri.org/Add" style="document" /> <input> <soap:body use="literal" /> </input> <output> <soap:body use="literal" /> </output> </operation> <operation name="Subtract"> <soap:operation soapAction="http://tempuri.org/Subtract" style="document" /> <input> <soap:body use="literal" /> </input> <output> <soap:body use="literal" /> </output> </operation> <operation name="Multipl"> <soap:operation soapAction="http://tempuri.org/Multipl" style="document" /> <input> <soap:body use="literal" /> </input> <output> <soap:body use="literal" /> </output> </operation> <operation name="Divided"> <soap:operation soapAction="http://tempuri.org/Divided" style="document" /> <input> <soap:body use="literal" /> </input> <output> <soap:body use="literal" /> </output> </operation> </binding> <binding name="Calc1HttpGet" type="s0:Calc1HttpGet"> <http:binding verb="GET" /> <operation name="Add"> <http:operation location="/Add" /> <input> <http:urlEncoded /> </input> <output> <mime:mimeXml part="Body" /> </output> </operation> <operation name="Subtract"> <http:operation location="/Subtract" /> <input> <http:urlEncoded /> </input> <output> <mime:mimeXml part="Body" /> </output> </operation> <operation name="Multipl"> <http:operation location="/Multipl" /> <input> <http:urlEncoded /> </input> <output> <mime:mimeXml part="Body" /> </output> </operation> <operation name="Divided"> <http:operation location="/Divided" /> <input> <http:urlEncoded /> </input> <output> <mime:mimeXml part="Body" /> </output> </operation> </binding> <binding name="Calc1HttpPost" type="s0:Calc1HttpPost"> <http:binding verb="POST" /> <operation name="Add"> <http:operation location="/Add" /> <input> <mime:content type="application/x-www-form-urlencoded" /> </input> <output> <mime:mimeXml part="Body" /> </output> </operation> <operation name="Subtract"> <http:operation location="/Subtract" /> <input> <mime:content type="application/x-www-form-urlencoded" /> </input> <output> <mime:mimeXml part="Body" /> </output> </operation> <operation name="Multipl"> <http:operation location="/Multipl" /> <input> <mime:content type="application/x-www-form-urlencoded" /> </input> <output> <mime:mimeXml part="Body" /> </output> </operation> <operation name="Divided"> <http:operation location="/Divided" /> <input> <mime:content type="application/x-www-form-urlencoded" /> </input> <output> <mime:mimeXml part="Body" /> </output> </operation> </binding> <service name="Calc1"> <port name="Calc1Soap" binding="s0:Calc1Soap"> <soap:address location="http://localhost/FourFunctionCalc/Calc1.asmx" /> </port> <port name="Calc1HttpGet" binding="s0:Calc1HttpGet"> <http:address location="http://localhost/FourFunctionCalc/Calc1.asmx" /> </port> <port name="Calc1HttpPost" binding="s0:Calc1HttpPost"> <http:address location="http://localhost/FourFunctionCalc/Calc1.asmx" /> </port> </service> </definitions>

A: The service, called Calc1, exposes four methods:

Add(iNum1 as Int, iNum2 as Int) as Int
Subtract(iNum1 as Int, iNum2 as Int) as Int
Multipl(iNum1 as Int, iNum2 as Int) as Int
Divided(iNum1 as Int, iNum2 as Int) as Int
  • + Share This
  • 🔖 Save To Your Account