Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web...
-
Upload
randolph-wilkerson -
Category
Documents
-
view
212 -
download
0
Transcript of Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web...
Web ServicesWeek 7
Aims:A detailed look at the underlying mechanisms for communication between web services
Objectives:
SOAP, WSDL, UDDI
Can call a web service with HTML form via HTTP GET
http://../MyGreeting.asmx/GreetingMethod?yourName=fred+bloggs
Returns XML
<?xml version="1.0" encoding="utf-8" ?> <string xmlns="http://tempuri.org/">Hello there fred bloggs</string>
Clearly limited to simple variables and simple uses (e.g. testing)
SOAP
• Simple Object Access Protocol
• Supports two message patterns– Client sends to server– Request Response Interaction
• Allows the passing to and fro of structured data• Based on XML
SOAP Requests and Responses •Visual Studio.NET displays format of SOAP requests and responses
•SOAP sent via HTTP
•Data sent and received in SOAP Envelopes
SOAP Request:Tags of The SOAP Envelope
• <soap:Envelope…>…</soap:Envelope>– this details standard schemas used
• <soap:Body>…</soap:Body>– this encapsulates data sent to web service method .
• <GreetingMethod xmlns="http://URL/">…</GreetingMethod>– the name and location of the web service method.
• <yourName>string</yourName>– the method’s input argument.
SOAP Response:Tags of The SOAP Envelope
• <soap:Envelope…>…</soap:Envelope>– this details standard schemas used
• <soap:Body>…</soap:Body>– this encapsulates data returned by the web service method .
• <GreetingMethodResonse xmlns="http://URL/">…</GreetingMethodResponse>– the name and location of the web service method.
• <GreetingMethodResult>string</GreetingMethodResult>– Data returned from the method.
Serialisation of Objects and Arrays
• A powerful aspect of SOAP is its ability to pass sophisticated multivariate objects and arrays.
• To do so the object or array is split up into an ordered stream of respective data elements (i.e. serialised).
• EXERCISE 7.1– Simple greeting service
• EXERCISE 7.2– Greeting method with multiple arguments– Consume web service
• EXERCISE 7.3– Passing classes and objects – Hence soap serialisation
A Closer Look at WSDL
• Web Service Description Language
• An XML Schema that describes a class
• Hence has elements, attributes, facets, simple types and complex types
• Indicates of how to use web service
• Is used to create proxy classes to instantiate local objects representing the remote web services.
Some WSDL to describe method<s:element name="MyGreeting"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name=“instr" type="s:string" /> </s:sequence> </s:complexType></s:element>
<s:element name="MyGreetingResponse"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="MyGreetingResult"
type="s:string" /> </s:sequence> </s:complexType></s:element>
WSDL to describe complex data<s:complexType name="Person“> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="name" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="address" type="s:string" /> <s:element minOccurs="1" maxOccurs="1" name="age" type="s:int" /> <s:element minOccurs="1" maxOccurs="1" name="height" type="s:float" /> <s:element minOccurs="1" maxOccurs="1" name="weight" type="s:float" /> <s:element minOccurs="1" maxOccurs="1" name="sex" type="s1:char" /> </s:sequence></s:complexType>
The above represents the class ‘Person’
public class Person
{
public string name, address;
public int age;
public float height, weight;
public char sex;
}
Universal Description Discovery Integration (UDDI)
• Wed services must be discovered before they can be consumed
• Visual Studio.NET gives a directory of Web Services awaiting discovery