WebService Descripttion Language (WSDL)

Một phần của tài liệu LUẬN VĂN:NGHIÊN CỨU XÂY DỰNG ỨNG DỤNG HỌC TIẾNG ANH THEO NGỮ CẢNH TRÊN THIẾT BỊ DI ĐỘNG doc (Trang 32 - 34)

WSDL là một định dạng XML để mô tả các dịch vụ Web Service và cách thức client truy cập và sử dụng các dịch vụđó.

Hình 3.4-2 Cấu trúc chung của một văn bản WSDL

Cấu trúc chung của một văn bản WSDL bao gồm 5 element chính :

Type : optional, cung cấp định nghĩa các kiểu dữ liệu được sử dụng ở các thông

điệp. Các định nghĩa kiểu dữ liệu thường được viết trong hệ thống XSD(extensible schema definition).

Ví dụ : Sử dụng 1 XSD bên ngoài Method : String SayHello ( String name )

<types>

<xsd:schema>

<xsd:import namespace=http://eg/

schemaLocation="HelloService_schema1.xsd" /> </xsd:schema>

26

</types>

Message : Định nghĩa các thông điệp sử dụng trong web service. Thứ tự của các

message phản ánh cách hoạt động của web service: request/response hay

solicit/response. Tên của các message có dạng ---In/---Out; ---Request/---Response với ‘---‘ phản ảnh operation liên kết với message.

<message name="SayHelloSoapIn">

<part name="parameters" element="tns:SayHello"/> </message>

<message name="SayHelloSoapOut">

<part name="parameters" element="tns:SayHelloResponse"/> </message>

Port type : biểu diễn dịch vụ như là một tập named operation, mỗi operation được mô tả bởi các input/output message . Nó giống như là một interface trong ngôn ngữ

Java: cho biết các operation và message nhưng không cho biết cài đặt bên trong.

<portType name="HelloServiceSoapPortType"> <operation name="SayHello"> <input message="tns:SayHelloSoapIn"/> <output message="tns:SayHelloSoapOut"/> </operation> </portType>

Binding : Mô tả các chi tiết rõ ràng của web service. Nó giống như là lớp cài đặt một interface trong Java.

<binding name="HelloServiceSoap“ type="tns:HelloServiceSoapPort"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> <operation name="SayHello"> <soap:operation soapAction="http://mspress.microsoft.com/ corexml/SayHello"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </binding>

27

Service : Định nghĩa một hoặc nhiều endpoint mà service hoạt động. Một endpoint

được mô tả là một URL mà các message có thể gửi tới để mà sử dụng dịch vụ. Service sẽ liệt kê một hoặc nhiều port, mỗi port gồm một portType (interface) và một binding(implementation). Thuật ngữ ‘port’ là lấy từ giao thức TCP, trong đó, một kết nối được mô tả bởi một cặp <IPAddress, PortNumber>, mỗi port tại một IPAdress sẽ

phục vụ một dịch vụ nhất định. <service name="HelloService"> <port name="HelloServiceSoap" binding="tns:HelloServiceSoap"> <soap:address location="http://localhost/HelloService.asmx"/> </port> </service>

Một phần của tài liệu LUẬN VĂN:NGHIÊN CỨU XÂY DỰNG ỨNG DỤNG HỌC TIẾNG ANH THEO NGỮ CẢNH TRÊN THIẾT BỊ DI ĐỘNG doc (Trang 32 - 34)