5
 Tutorial 3 1. Why i s a se rvic e des cri pt ion n eces sa ry for r epre sent ing Web se rvices? Answer: Web services need to be des cr ibed as we are de velopi ng ser vi ce-bas ed applic at ion (assemble the services). Af te r de sc ri be d, WS ca n be pu bl is he d, di sc ov er ed, as se mble d in a managea bl e hierarchy to deliver value-added service solution. Service des cri pti on is t ypi cal ly us ed to makin g SOA l oos ely c oup led. Ser vic e de scr ipti on is a mach ine- und ers tan dable spe cif ica tion des cri bing the str uct ure , operational characteristics, and non-functional properties of a Web service. It a lso spe cif ies the wir e format and tr ans por t proto col . 2. What is the purpose of the Web Services Description Language (WSDL)? Answer: WSDL is the se rv ice re pr esenta ti on langu age us ed to de sc ri be the de tail s of th e complete interfaces exposed by Web services and thus is the means to accessing a Web service. Thr oug h the serv ice des cri pti on, se rvi ce prov ider ca n commu nic ati on all the spe cs for invoking WS to the service requestor. WSDL is an XML-ba sed s pec ific ati on sc hema for de scr ibi ng the publ ic int erf ace of a Web service. Thi s in te rf ace inc lu de :  Ope rat ional in for mat ion rel atin g to a We b s erv ice  XML mes sag e pr otocol s su ppo rte d by a We b se rvic e  Dat a type info rma tion for messa ges , bindi ng info rma tion (s pec ific pr otocol to  be used) .  Add res s infor mat ion for loc atin g the We b se rvi ce. WSDL al lows the specif icat ion for trans mi ss ion under SOAP. Both service pr ovide r and service reques tor must agree WS desc ri pt ion and make use of that service. (a “contract” btw them) Essent ial ly, WSDL is used to describe pr ecisel y wha t a se rvi ce does , i.e . the ope rat ion t he s erv ice p rovide s, where it resides, i.e . det ails of th e pro toco l address, e .g. URL. how t o invo ke it, i .e. deta ils of t he da ta for mat s and prot oco ls nec essary. 3. Defin e a nd desc ri be the Web s er vi ce interf ace ( abst ract interf ac e) . Answer: The s ervice inter face defin ition desc ribes the g enera l Web serv ice i nterfa ce s tructu re. 1. Data type s - def ining data types in the for m of XML s chemas or pos si bl y oth er  mechanism. 2. Mess age - pres ent mes sage as ei ther as an ent ir e doc ument or arg uments to be mapped to a method (WS) invocation. 3. Op er at ion - th e abst ra ct defi ni ti on of the oper at ion fo r a me ssage, such as naming a method, message queue, or business process, that will accept and  process the message. 4. Port type - an abstract set of operations mapped to one or more end points (port), defining th e co ll ect io n of operations for a  b inding; th e co lle ct io n of op erat io ns, be ca use it is abs tr ac t, can  be mapped to multiple transports through various bindings. Page 1 of 5 Tunku Abdul Rahman College Advanced Diploma in Science  AACS5274 Web Services

Web Service - TUtorial 3 (Answer)

Embed Size (px)

Citation preview

Page 1: Web Service - TUtorial 3 (Answer)

5/12/2018 Web Service - TUtorial 3 (Answer) - slidepdf.com

http://slidepdf.com/reader/full/web-service-tutorial-3-answer 1/5

Tutorial 3

1. Why is a service description necessary for representing Web services?

Answer:

• Web services need to be described as we are developing service-based application(assemble the services).

• After described, WS can be published, discovered, assembled in a manageable

hierarchy to deliver value-added service solution.

• Service description is typically used to making SOA loosely coupled.

• Service description is a machine-understandable specification describing the structure,

operational characteristics, and non-functional properties of a Web service.

• It also specifies the wire format and transport protocol.

2. What is the purpose of the Web Services Description Language (WSDL)?

Answer:

• WSDL is the service representation language used to describe the details of the

complete interfaces exposed by Web services and thus is the means to accessing a Web

service.

• Through the service description, service provider can communication all the specs for 

invoking WS to the service requestor.

• WSDL is an XML-based specification schema for describing the public interface of a

Web service.

• This interface include:

 – Operational information relating to a Web service

 – XML message protocols supported by a Web service

 – Data type information for messages, binding information (specific protocol to

 be used) . – Address information for locating the Web service.

• WSDL allows the specification for transmission under SOAP.

• Both service provider and service requestor must agree WS description and

make use of that service. (a “contract” btw them)

• Essentially, WSDL is used to describe precisely

• what a service does, i.e. the operation the service provides,

• where it resides, i.e. details of the protocol address, e.g. URL.

• how to invoke it, i.e. details of the data formats and protocols necessary.

3. Define and describe the Web service interface (abstract interface).

Answer:

• The service interface definition describes the general Web service interface structure.

1. Data types - defining data types in the form of XML schemas or possibly other 

mechanism.

2. Message - present message as either as an entire document or arguments to be

mapped to a method (WS) invocation.

3. Operation - the abstract definition of the operation for a message, such as

naming a method, message queue, or business process, that will accept and

 process the message.

4. Port type - an abstract set of operations mapped to one or more

end points (port), defining the collection of operations for a

  binding; the collection of operations, because it is abstract, can be mapped to multiple transports through various bindings.

Page 1 of 5

Tunku Abdul Rahman CollegeAdvanced Diploma in Science

 AACS5274

Web Services

Page 2: Web Service - TUtorial 3 (Answer)

5/12/2018 Web Service - TUtorial 3 (Answer) - slidepdf.com

http://slidepdf.com/reader/full/web-service-tutorial-3-answer 2/5

4. Define and describe the Web service implementation (concrete endpoint).

Answer:

• The service implementation binds the abstract interface to a concrete network address, to a

specific protocol, and to concrete data structure.

a) Binding - the concrete protocol and data formats for the operations and messages

defined for a particular port type.

 b) Port - a combination of a binding and a network address, providing the target address of 

the service communication.

c) Service - a collection of related end points (port) encompassing the service definitionsin the file; the services map the binding to the port and include any extensibility

definitions.

5. Can a single service contain multiple ports? What is the implication?

Answer:

Yes. It can contain multiple ports.

• A port identifies one or more transport binding for a given port type.

• Port types can be grouped for binding(s) which is how the services are connected over 

network.

6. How does one-way operation differ from a request/response operation?

Answer:

One-way operation• An operation in which the service endpoint receives a message, but

does not send a response. E.g. a submission of an order to a purchasing

system, no immediate response.

• Thought of as asynchronous messaging and defines only input

message.

Request/response operation

• An operation in which the service endpoint receives a message and

returns a message in response. (similar with RPC-style).

• <operation> element is declared with a <input> (indicates a WS

receives a msg) and followed by a <output> (indicates a WS responds to the

msg) element, it defines a request/response operation.

Page 2 of 5

 

Page 3: Web Service - TUtorial 3 (Answer)

5/12/2018 Web Service - TUtorial 3 (Answer) - slidepdf.com

http://slidepdf.com/reader/full/web-service-tutorial-3-answer 3/5

7. How does a notification operation differ from a solicit/response operation?

Answer:

 Notification operation

• An operation in which the service endpoint sends a message to a client,

 but it does not expect to receive a response.

• This type of messaging is used by services that need to notify clients of 

event e.g subscriber 

• It contains an <output> element but no <input> message.

Solicit/response operation

• An operation in which the service endpoints sends message and

expects to receive an answering message in response. (opposite of 

request/response operation)

• In this messaging pattern, the <portType> first declares <output> and

then an <input> element. E.g service sends a order status to a client and

receives back a receipt.

8. With the aid of a diagram, explain how the WSDL architecture works.

Answer:

Role of a WSDL file in a Web services interaction:

• When a Web service is published, a Web service administrator posts a

link to the Web service’s WSDL document in an XML registry /WSDL

repository.

• The WSDL file is available when an application, such as SOAP client,

searches a registry to locate a Web service. A client accesses the

WSDL document in WSDL Repository to acquire information aboutthe Web service and to create a SOAP message with the appropriate

structure to communicate with the service.

• Then, using the information in the WSDL document, the client invokes

Page 3 of 5

 

XML Registry or WSDL

Repository

Web

ServicesClient

2. Retrieve

WSDL

document

1. Web Services

administrator 

 posts WSDL

document to

WSDL

repository

3. Invoke

Page 4: Web Service - TUtorial 3 (Answer)

5/12/2018 Web Service - TUtorial 3 (Answer) - slidepdf.com

http://slidepdf.com/reader/full/web-service-tutorial-3-answer 4/5

the Web service.

9. What TWO (2) purposes does the <binding> element serve?

Answer:

- The binding element links the abstract elements with the concrete elements of the WSDL.

- It provides a container for information like protocol and address of the service.

10. Based on the Web Services Description Language (WSDL) document given below, identify and explain

each of the WSDL elements in detail.

1 <?xml version="1.0" encoding="utf-8" ?>

2 <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

3 xmlns:tns="http://tempuri.org/"

4 xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"

5 targetNamespace="http://tempuri.org/"

6 <wsdl:types>

7 <s:element name="calculateSalary">

8 <s:complexType>

9 <s:sequence>

10 <s:element minOccurs="1" maxOccurs="1" name="basic" type="s:int" />11 <s:element minOccurs="1" maxOccurs="1" name="OT" type="s:int" />

12 </s:sequence>

13 </s:complexType>

14 </s:element>

15 <s:element name="calculateSalaryResponse">

16 <s:complexType>

17 <s:sequence>

18 <s:element minOccurs="1" maxOccurs="1" name="Result" type="s:int" />

19 </s:sequence>

20 </s:complexType>

21 </s:element>

22 </s:schema>

23 </wsdl:types>

24 <wsdl:message name="calculateSalarySoapIn">

25 <wsdl:part name="parameters" element="tns:calculateSalary" />

26 </wsdl:message>

27 <wsdl:message name="calculateSalarySoapOut">

28 <wsdl:part name="parameters" element="tns:calculateSalaryResponse" />

29 </wsdl:message>

30 <wsdl:portType name="ServiceSoap">

31 <wsdl:operation name="calculateSalary">

32 <wsdl:input message="tns:calculateSalarySoapIn" />

33 <wsdl:output message="tns:calculateSalarySoapOut" />

34 </wsdl:operation>

35 </wsdl:portType>

36 <wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">

37 <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />

38 <wsdl:operation name="calculateSalary">

39 <soap:operation soapAction="http://tempuri.org/calculateSalary"40 style="document" />

41 <wsdl:input>

42 <soap:body use="literal" />

43 </wsdl:input>

44 <wsdl:output>

45 <soap:body use="literal" />

46 </wsdl:output>

47 </wsdl:operation>

48 </wsdl:binding>

49 <wsdl:service name="Service">

50 <wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">

51 <soap:address location="http://localhost:WebSite/Service.asmx" />

52 </wsdl:port>

53 <wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">

54 <soap12:address location="http://localhost:WebSite2/Service.asmx" />

55 </wsdl:port>

56 </wsdl:service>

57 </wsdl:definitions>

Page 4 of 5

Page 5: Web Service - TUtorial 3 (Answer)

5/12/2018 Web Service - TUtorial 3 (Answer) - slidepdf.com

http://slidepdf.com/reader/full/web-service-tutorial-3-answer 5/5

Page 5 of 5