Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web...

12
Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI

Transcript of Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web...

Page 1: Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI.

Web ServicesWeek 7

Aims:A detailed look at the underlying mechanisms for communication between web services

Objectives:

SOAP, WSDL, UDDI

Page 2: Web Services Week 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)

Page 3: Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI.

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

Page 4: Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI.

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

Page 5: Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI.

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.

Page 6: Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI.

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.

Page 7: Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI.

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).

Page 8: Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI.

• 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

Page 9: Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI.

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.

Page 10: Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI.

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>

Page 11: Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI.

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;

}

Page 12: Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI.

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