Suranglutch Chaokoksoohng

Slides:



Advertisements
งานนำเสนอที่คล้ายกัน
J2EE Architecture for Web Application & Enterprise Programming
Advertisements

E-COMMERCE WEBSITE Smartzap Co., Ltd.. Company Profile บริษัท สมาร์ทแซป จำกัด ก่อตั้งเมื่อปี 2543 (13 ปี ) ในช่วงยุค Internet เพิ่ง เริ่มต้น เป็นบริษัทที่ดำเนินงานทางด้าน.
John Rawls  John Rawls is the most famous American social contract theorist argued that “Justice is fairness” He Thought human natural have a appropriate.
Accounting and ERP Software by Crystal Software Group
หลักการและแนวคิดการนำ สื่ออิเล็กทรอนิกส์ มาใช้ใน การเรียนการสอน ผศ. นพ. ทรงพล ศรีสุโข 30 ก. ย
THE PARTS OF A FLOWERING PLANT AND THEIR FUNTION.
Set is a basic term in Mathematics. There is no precise definition for term “set”, But roughly speaking, a set is a collection of objects, Things or symbols,
ขั้นตอนวิธีและเครื่องมือในการพัฒนาโปรแกรม (ต่อ)
จำนวน สถานะ NUMBER OF STATES. ประเด็นที่ สนใจ The number of distinct states the finite state machine needs in order to recognize a language is related.
INTELLECTUAL CAPITAL : IC Group 3: Tipada Subhasean Nongluk Charoeschai Nerisa Wangkarat
Chapter 10 : Finalizing Design Specification
Chapter 9 : Designing Approach
Graphical User Interface charturong.ee.engr.tu.ac.th/CN208
Braille OCR Mobile Application
รู้จักกับเทคโนโลยี RFID เบื้องต้น
Emergency Response System for Elderly and PWDs: Design & Development
Database Management System
VARIABLES, EXPRESSION and STATEMENTS. Values and Data Types Value เป็นสิ่งพื้นฐาน มีลักษณะเป็น ตัวอักษร หรือ ตัวเลข อาทิ 2+2 หรือ “Hello world” Value.
อาจารย์ มธ. อธิบายการใช้ โมเดลของ
Data Structures and Algorithms
ระบบการจัดเก็บในคลังสินค้า
: Chapter 1: Introduction 1 Montri Karnjanadecha ac.th/~montri Image Processing.
Color Standards A pixel color is represented as a point in 3-D space. Axis may be labeled as independent colors such as R, G, B or may use other independent.
ออโตมาตาจำกัด FINITE AUTOMATA
REGULAR EXPRESSION การบรรยายแบบสม่ำเสมอ
Helping you make better treatment decisions for your patients.
Chapter 19 Network Layer: Logical Addressing
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
Client-Side Scripts เอกสารประกอบการบรรยาย รายวิชา Browser-Based Application Development.
Inductive, Deductive Reasoning ผศ.( พิเศษ ) น. พ. นภดล สุชาติ พ. บ. M.P.H.
Course Software Engineering SE Overview and Introduction.
Computer Graphics.
Web Services.
INC341 Steady State Error Lecture 6.
        วงจรดิจิตอลลอจิก 3(2-1-3)
Hyper Text Transfer Protocol
Stored Procedure.
การออกแบบและพัฒนาซอฟต์แวร์ บทที่ 7 การทดสอบโปรแกรม
Create the Knowledge Management Blueprint
8/3/2014The Realities of software Testing1 Software testing Realities What is the realities of software testing Why does the software testing not complete.
Merchant Marine Training Centre วิชาการเป็นเลิศ เชิดชู คุณธรรม ผู้นำ.
Page: 1 โครงสร้างคอมพิวเตอร์ และภาษาแอสเซมบลี้ ผศ. บุรินทร์ รุจจน พันธุ์.. ปรับปรุง 19 ตุลาคม 2555 Introduction to Batch.
Page: 1 โครงสร้างคอมพิวเตอร์ และภาษาแอสเซมบลี้ Gate & Karnaugh Map มหาวิทยาลัยเนชั่น จังหวัดลำปาง
โดย นรฤทธิ์ สุนทรศารทูล สถาบันเทคโนโลยีพระจอมเกล้าเจ้าคุณทหารลาดกระบัง
Menu and Interactive with Powerpoint ให้นำเรื่อง Input /Output Technology มา จัดทำ การนำเสนอ โดยใช้หลักการ Menu and Interactive with powerpoint มาประยุกต์
Enhanced Entity-Relationship Model © Pearson Education Limited 1995, 2005.
Algorithm Efficiency There are often many approaches (algorithms) to solve a problem. How do we choose between them? At the heart of computer program.
Writing a research. Why Research?  To find whether the messages and the materials are appropriate to the target group  To modify the messages and the.
Java Programming Language สาขาวิชาระบบสารสนเทศ คณะบริหารธุรกิจ มหาวิทยาลัยเทคโนโลยีราชมงคลกรุงเทพ.
Thread Thread ส่วนของ process ที่ให้ CPU ประมวลผล.
STACK ADT By Pantharee S.. Stack Model  A list with the restriction that insertions deletions can be performed in only one position (LIFO)  Push – insert.
1-1: Software Project Management การจัดการโครงงานซอฟต์แวร์ Software Project Management การจัดการโครงงานซอฟต์แวร์ ความหมายการจัดการโครงงาน.
วิธีการทำงานของ ตัวประมวลผลสารสนเทศมีการ ศึกษาวิเคราะห์ และออกแบบโครง สร้างหน้าที่ด้วยสถาปัตยกรรมองค์ประกอบ 6 ส่วน ในตัวประมวลผลสารสนเทศ ได้แก่……………..
การสร้าง WebPage ด้วย Java Script Wachirawut Thamviset.
Dianne J. Hall David B. Paradice James F. Courtney Proceedings of the 34th Hawaii International Conference on System Sciences
Chapter 3 Simple Supervised learning
Chapter 1/1 Arrays. Introduction Data structures are classified as either linear or nonlinear Linear structures: elements form a sequence or a linear.
An Online Computer Assisted Instruction Development of Electronics Devices Subject for Learning Effectiveness Testing By Assoc.Prof. Suwanna Sombunsukho.
The Analysis of Strands, Standards and Indicators for Tests
 Mr.Nitirat Tanthavech.  HTML forms are used to pass data to a server.  A form can contain input elements like text fields, checkboxes, radio-buttons,
PHP FRAMEWORK – Web Programming and Web Database Asst. Prof. Dr. Choopan Rattanapoka.
Multimedia Production
ที่มาและหน่วยงานกาชาดต่างๆ
Injection.
Web Services ศูนย์เชียวชาญฉพาะทางด้านวิศวกรรมซอฟต์แวร์
Speaker.
<insert problem title>
Workday Merit Process - Approvers
Extreme Programming Explained: Embrace Change
Xoserve IX Refresh Customer Update 03/09/2019.
ใบสำเนางานนำเสนอ:

Suranglutch Chaokoksoohng (suranglutch@gmail.com) 3# SOAP Simple Object Access Protocol and 4# Overview Web service by PHP Informatics BUU. Suranglutch Chaokoksoohng (suranglutch@gmail.com)

Bind | SOAP: Simple Object Access Protocol Service Registry Provider Requestor Publish Bind Find UDDI SOAP WSDL Bind | SOAP: Simple Object Access Protocol

SOAP in a nutshell “SOAP is a protocol specification for invoking methods on servers, services, components and objects. SOAP codifies the existing practice of using XML and HTTP as a method invocation mechanism. The SOAP specification mandates a small number of HTTP headers that facilitate firewall/proxy filtering. The SOAP specification also mandates an XML vocabulary that is used for representing method parameters, return values, and exceptions.” [DevelopMentor] Like XML-RPC, SOAP was developed to be a platform and language independent method of passing information between services, objects, and servers. Provides a simple standardized mechanism for moving structured information.

What is SOAP? Protocol ในการสื่อสารกันระหว่าง Application กำหนดรูปแบบในการส่งผ่านข้อความโดยผ่านเครือข่ายอินเทอร์เน็ต ไม่ขึ้นกับ Platform และภาษาคอมพิวเตอร์ที่พัฒนา มีโครงสร้างแบบ XML SOAP Message เป็นข้อความที่ใช้ส่งผ่านเครือข่ายอินเทอร์เน็ต และเมื่อใช้ร่วมกับเว็บ สามารถส่งผ่าน Firewall ได้ไม่ยาก ได้รับการดูแลโดย W3C *** - เดิมย่อมาจาก Simple Object Access Protocol แต่ถูก drop ไป เพราะไม่เกี่ยวกับ OO บางคนก็ไม่ถือว่าเป็นชื่อย่อ บางคนเรียกว่าเป็น Service-Oriented Access Protocol เพราะนำมาใช้ในโลกของ Web Services - SOAP เป็น XML messaging protocol ที่ lightweight เพราะ เมื่อเทียบกับพวก CORBA, DCOM, RMI จะเบากว่าเพราะไม่มีองค์ประกอบ เช่น การ register และ locate service แต่อาศัยว่าไปพึ่งมาตรฐานอื่น เช่น UDDI (register) และ WSDL (locate) - SOAP ทำ type mapping จาก native language object โดยการ marshall ไปเป็น XML เพื่อจะใส่ใน SOAP message ได้ ปกติ SOAP toolkit จะมี predefined translator สำหรับ primitive types, collections, MIME attachment แต่ถ้าเป็น custom (class) object ก็ต้องสร้าง (class ที่เป็น) serializer และ deserializer เองและไป register ไว้ทั้งฝั่ง client และ server - สามารถใช้ติดต่อระหว่างโปรแกรมคนละภาษาคนละ OS ได้ เช่น Perl บน Solaris คุยกับ Java บน Windows 2000 ได้ และมี SOAP toolkit สำหรับพัฒนา SOAP message ออกมาโดยหลาย vendor เช่น Apache, IBM, Microsoft, BEA, Sun (SAAJ) ภาษาที่ใช้พัฒนาเช่น Java, C++, C#, VB, Perl - SOAP สามารถใช้ได้กับหลาย transport protocol เช่น HTTP, SMTP, FTP, JMS แต่ที่นิยมคือ HTTP - SOAP สามารถผ่าน firewall ได้ ไม่ต้องทำอะไรเพิ่ม ถ้าเป็น protocol เช่น CORBA, DCOM ต้องไปเปิด port บน firewall ดังนั้นในแง่ของ distributed system ซึ่งต้องติดต่อกับ external system นอก firewall จึงสะดวกขึ้น - SOAP ยังมีปัญหาเรื่อง interoperability ระหว่าง SOAP toolkit อยู่ อันเนื่องมาจาก SOAP spec ยังไม่ mature เต็มที่ และก็มีปัญหาเกี่ยวกับพวก guaranteed messaging และ security policy

SOAP Messaging Service Application Internet Client Application SOAP HTTP SOAP Message HTTP SOAP Message Service Application Client Application Internet

Where did it come from? Microsoft, UserLand, DevelopMentor, IBM, Ariba, Commerce One, Compaq, HP, IONA, Lotus, SAP ~ Submitted to W3C May 2000. XML based protocol Intended to be a simple wire-protocol for exchange of info. Largest use may be over Internet HTTP.

W3C July 9, 2001 W3C Releases First Public Working Draft for SOAP Version 1.2 Working draft produced by the XML Protocol Working Group. Specification can be found: http://www.w3.org/TR/soap12/

Motivation Many Distributed applications communicate using remote procedure calls (RPC) between distributed objects like DCOM and CORBA. HTTP isn’t designed for those objects, so RPC calls aren’t easily adapted to the Internet. Security problems exist for those methods of RPC, so most firewalls and proxy servers are set to block this traffic. HTTP is supported by all Internet browsers and servers, so SOAP presents a nice protocol for doing RPC.

SOAP suds SOAP IS: Lightweight communication protocol For communication between applications one-way, request/response, multicast, etc.. Designed to communicate via HTTP Not tied to any component technology Not tied to any programming language Based on XML Simple and extensible

Loose Coupling หลักการออกแบบ Application ที่เน้นการปรับ เข้ากับสิ่งที่เปลี่ยนแปลงไปได้โดยง่าย (Agility) ลดความขึ้นต่อกัน ระหว่างองค์ประกอบ เพื่อให้มีความคล่องตัว เป็นเป้าหมายของ SOA

Loose Coupling in SOA Heterogeneous Technologies // Tightly Coupled SOA ใช้ Standardized Interface แทนการใช้ Standardized Code อิสระในการพัฒนา Service ด้วยเทคโนโลยีใดก็ได้ ได้ Technology Decoupling โดยยอมเสีย Interface Coupling Data Exchange // all platforms SOA ใช้รูปแบบข้อมูลที่อิสระกับเทคโนโลยี หลีกปัญหา Low-Level Data-Type Compatibility Published Schema // Easy to find all service Service Directory ช่วยในการตกลงเรื่องการให้บริการอย่าง Dynamic Delayed Binding // Can change Version, no new compile – no new application Binding ทำตอนเรียกใช้ Service และยึด Standardized Interface การเปลี่ยนแปลง Service Implementation ไม่กระทบผู้ใช้ แง่ Heterogeneous Technology - Service จะ implement ด้วยภาษาใดบนแพลตฟอร์มใดก็ได้ แต่ในยุคก่อน ซอฟต์แวร์จะติดต่อกันได้ต้องมีอะไรบางอย่างเหมือนกัน จึง tightly coupled กว่า แง่ Data Exchange - การใช้ข้อมูลรูปแบบมาตรฐานที่ไม่ขึ้นกับแพลตฟอร์ม ทำให้ไม่มีปัญหาเรื่อง representation ของข้อมูลที่แลกเปลี่ยน แง่ Published Schema – Service Directory ทำให้ค้นหา Service ที่ต้องการติดต่อได้แบบ dynamic และช่วยให้ศึกษารูปแบบ Interface และรูปแบบข้อมูลเพื่อติดต่อได้อย่างสะดวก แทนการตกลงติดต่อกันแบบ manual แง่ Delayed Binding – การเปลี่ยนแปลง Service Implementation หรือเปลี่ยนเวอร์ชันไม่ได้ต้องการ Application ให้ compile ใหม่ เพราะ bind เมื่อเรียกใช้

General (Basic) Structure SOAP Message Envelope Defines the content of the message Header (optional) contains header information Body contains call and response information

SOAP Message Structure SOAP Envelope SOAP Message SOAP Header SOAP Body XML Message XML Message (RPC or Doc) SOAP สามารถ extend ได้โดยเพิ่มข้อมูลในส่วน Header เช่น ข้อมูลเพื่อทำ authentication ข้อมูลบัญชีเพื่อให้หักเงิน pay-per-use ข้อมูล context สำหรับใช้ปรับการให้บริการ etc. SOAP Message ≠ XML Message

SOAP Messaging Service Application Internet Client Application SOAP HTTP SOAP Message HTTP SOAP Message Service Application Client Application Internet

SOAP with Attachment (SwA) SOAP มักจะมี XML Message อยู่ในส่วน Body SwA เป็นทางเลือกในการส่ง XML Message ขนาดใหญ่มาก หรือ Message ที่ไม่ได้เป็น XML-based เช่น รูปภาพ Binary ขนาดใหญ่ หรือแฟ้มเสียง MP3 ขนาดใหญ่ เป็นต้น ใช้ MIME multipart/related media type และการอ้างอิงโดยURI ในส่วนต่าง ๆ ของ MIME ถึง Attachment ที่ต้องการ ได้รับการดูแลโดย W3C ถ้าต้องการส่งนอกเหนือจาก text message คือ ส่ง custom data type เช่น array of data structures หรือ binary file, complex data file บาง SOAP toolkit ไม่ support attachment (SAAJ มี ส่วน Microsoft ใช้แบบ based on DIME)

SwA Structure Part 1 SOAP Message Part 2 Attachment Image **** MIME-Version:1.0 Content-Type:Multipart/Related;boundary=MIME_boundary;type=text/xml; start=“http://myURL/soap/attachments/fileupload1” --MIME boundary Part 1 Content-Type:text/xml;charset=utf-8 Content-Transfer-Encoding:8bit Content-ID:<data061400a.xml.apache-soap.joshyjjp”/> <?xml version=“1.0”?> <SOAP:Envelope> … <theSignedForm href=“cid:gif061400a.xml.apache-soap.joshyjjp”/> </SOAP:Envelope> SOAP Message **** - ข้อมูลที่เกี่ยวข้องที่อยู่นอก SOAP Envelope เป็น format อะไรก็ได้ - MIME คือ Multipurpose Internet Mail Extension เป็น Internet standard สำหรับส่งข้อมูลไปใน email นอกเหนือจาก US-ASCII (ภาษาอังกฤษ) เช่น text ในภาษาอื่น และ binary content ได้แก่ image, sound, movie, computer program หรือ multi-part message MIME เป็น component พื้นฐานใน HTTP ด้วย คือใช้แม้ว่าจะไม่ได้เป็นการส่ง email - จากรูป ทั้งหมดนี้เป็น SOAP message package ที่สร้างโดยใช้ MIME Multipart/Related media type แต่ละส่วนของ message จะอยู่ใน MIME boundary คืออยู่ภายใต้ Content-Type header ซึ่งบอกถึงชนิดข้อมูลที่อยู่ในส่วนนี้ ส่วน Content-Transfer-Encoding บอกถึงการ encoding สำหรับส่วนนี้ ส่วน Content-ID จะบอก ID สำหรับใช้อ้างถึงข้อมูลส่วนนี้จากส่วนอื่นใน MIME package - ส่วน root ของ MIME message (สีชมพู) จะห่อ SOAP Envelope และมี Content-Type เป็น text/xml - ส่วนของ SOAP Header และ SOAP Body จะอ้างอิง attachment โดยใช้ attribute href จากรูปแสดงถึงข้อมูล theSignedForm ที่ส่งใน SOAP message จะอ้างถึง URI ของ ส่วน attachment - ถ้าใช้ HTTP binding ส่วน MIME parts ทั้งหมดจะเป็น HTTP body Part 2 Content-Type:image/gif Content-Transfer-Encoding:binary Content-ID:<gif061400a.xml.apache-soap.joshyjjp> …gif image Attachment Image

Envelope MUST be associated with SOAP envelope namespace: http://www.w3.org/2001/06/soap-envelope SOAP serialization namespace: http://www.w3.org/2001/06/soap-encoding Encoding Style attributes can contain a URI describing how the data should be serialized. SOAP message MUST NOT contain a DTD or Processing Instructions.

SOAP Namespaces The SOAP envelope has the namespace identifier “http://www.w3.org/2001/06/soap-envelope” The SOAP serialization has the namespace identifier "http://www.w3.org/2001/06/soap-encoding" The SOAP mustUnderstand fault namespace identifier "http://www.w3.org/2001/06/soap-faults" The SOAP upgrade namespace identifier "http://www.w3.org/2001/06/soap-upgrade"

Header Optional. If present, must immediately follow the SOAP Envelope XML element followed by any header entries. Often contains meta-information regarding the method call. Actor attribute who should process message mustUnderstand attribute how to process(default is “0” if not present) <env:Header> <t:Transaction xmlns:t=“some-URI” env:mustUnderstand=“1”> 5 </t:Transaction> </env:Header>

Body Message to exchange. Most often for RPC calls and error reporting. Immediate child element of SOAP Envelope XML element (follows Header, if present). Contains serialized method arguments. Remote method name is used to name the method call’s XML element and must immediately follow the SOAP body opening XML tag.

That’s the basics…example A simple SOAP XML document requesting the price of soap. <env:Envelope> <env:Body> <m:GetPrice> <Item>Lever2000</Item> </m:GetPrice> </env:Body> </env:Envelope>

SYNTAX RULES MUST be encoded using XML MUST have a SOAP Envelope CAN have a SOAP header MUST have a SOAP Body MUST use the SOAP Envelope namespace MUST use the SOAP Encoding namespace Must NOT contain a DTD reference Must NOT contain XML Processing

ERRORS: SOAP Fault Element Error messages from a SOAP application are carried inside a Fault element. Must appear as an element w/in the <Body> element and can only appear once in a SOAP message. Fault sub elements: <faultcode> MUST: --code identifying the error, for use by the software <faultstring> MUST: --error as a string <faultactor> MUST(Apps not acting as ultimate destination of SOAP message) --who caused the error <detail> MUST(if contents of Body could not be successfully processed) --specific error information Fault Codes: VersionMismatch Invalid namespace for the SOAP Envelope Element MustUnderstand A child element of the Header element, with the mustUnderstand attribute set to “1”, was not understood Client The message was incorrectly formed or contained incorrect information. Server There was a problem with the server so the message could not be process Example: <env:Fault> <faultcode>env:MustUnderstand</faultcode> <faultstring>SOAP Must Understand Error</faultstring> </env:Fault>

Easy Transport….HTTP Why HTTP? HTTP has a request/response model allowing SOAP to embed request parameters in HTTP request, and SOAP response parameters into HTTP responses. HTTP apps MUST use the media type “text/xml” when including SOAP entity bodies in HTTP messages. Content-Type: text/xml; charset=“utf-8” SOAP HTTP Header info Basicly…sending XML formatted messages across the network using HTTP.

Part of the HTTP payload Commonly used with HTTP protocol (response/request model) thereby making it very scalable. SOAPAction HTTP Header Field. SOAPAction: “Some-URI” Firewall access? Most firewalls/proxies are opened to port 80 for HTTP giving SOAP a widely used transport protocol across distributed systems. The SOAPAction HTTP header field allows firewalls/proxys to filter SOAP messages if desired. Security? No security has been implemented with SOAP, but consider HTTPS/SSL.

Stock Quote example embedded in an HTTP POST Request POST /StockQuote HTTP/1.1 Host: www.stocksserver.com Content-Type: text/xml; charset=“utf-8” SOAP HTTP Header info Content-Length: nnnn SOAPAction: “Some-URI” SOAP HTTP Header info <env:Envelope xmlns:env=“http://www.w3.org/2001/06/soap-envelope”> <env:Body> <m:GetStockQuote xmlns:m=“Some-URI” env:encodingStyle=“http://www.w3.org/2001/06/soap-encoding”> <symbol>SUNW</symbol> </m:GetStockQuote > </env:Body> </env:Envelope> Sent from the client to the service. First few lines are HTTP headers and SOAP HTTP headers. Followed by the SOAPAction HTTP header and SOAP Envelope XML element. The SOAP Body contains application defined element(s), as defined by the service.

Stock Quote Response example embedded in HTTP Response HTTP/1.1 200 OK Content-Type: text/xml; charset=“utf-8” SOAP HTTP Header info Content-Length: nnnn <env:Envelope xmlns:env=http://www.w3.org/2001/06/soap-envelope”> <env:Body> <m:GetStockQuoteResponse xmlns:m=“Some-URI” env:encodingStyle=“http://www.w3.org/2001/06/soap-encoding”> <price>5.00</price> </m:GetStockQuoteResponse> </env:Body> </env:Envelope>

Client/Server… In order for SOAP to work, the client must have code running that is responsible for building the SOAP request. In response, a server must also be responsible for understanding the SOAP request, invoke the specified method, build the response message, and return it to the client. These details are up to you. There already exist SOAP implementations for languages such as Perl and Java.

SOAP box Inherently stateless if it uses HTTP for transport. Doesn’t implement security. However transport with HTTP allows for SSL and HTTPS at the application level. SOAPAction HTTP header field allows your firewall to filter SOAP method invocations/deny SOAP processing altogether. Firewall filters SOAP packets based on the object name, particular method, or a combo of the two.

SOAP for RPC Design goals of SOAP: simplicity & extensibility. RPC with XML allows for uniform representation of remote procedure calls and responses. You’re not limited to HTTP protocol binding…just a natural choice for the request/response model.

W3C Working Draft: 1. 3 Examples of SOAP Messages http://www. w3 “The first example shows a simple notification message expressed in SOAP. The message contains the header block "alertcontrol" and the body block "alert" which are both application defined and not defined by SOAP. The header block contains the parameters "priority" and "expires" which may be of use to intermediaries as well as the ultimate destination of the message. The body block contains the actual notification message to be delivered.” Example 0 <env:Envelope xmlns:env="http://www.w3.org/2001/06/soap-envelope"> <env:Header> <n:alertcontrol xmlns:n="http://example.org/alertcontrol"> <n:priority>1</n:priority> <n:expires>2001-06-22T14:00:00-05:00</n:expires> </n:alertcontrol> </env:Header> <env:Body> <m:alert xmlns:m="http://example.org/alert"> <m:msg>Pick up Mary at school at 2pm</m:msg> </m:alert> </env:Body> </env:Envelope>

Publish | Web Services Description Language: WSDL Registry Provider Requestor Publish Bind Find UDDI SOAP WSDL Publish | Web Services Description Language: WSDL

Web Services Description Language (WSDL) WSDL ได้รับการออกแบบพัฒนาโดยกลุ่มบริษัทผู้ผลิต ได้แก่ Microsoft, Ariba, IBM และบริษัทผู้ผลิตอื่น ๆ อีกกว่า 20 บริษัทร่วมกันสนับสนุน ข้อกำหนด WSDL ได้รับการส่งต่อไปให้ W3C (World Wide Web Consortium) ดูแลปรับปรุงต่อไป WSDL เป็นเสมือน De Facto Standard ในปัจจุบันสำหรับ การพัฒนา Web Services

WSDL Main Components Data types Message Operation Port type Binding Service ส่วนประกอบตาม WSDL 1.1 ปัจจุบัน (เม.ย 50) WSDL 2.0 ยังเป็น draft ที่ call for review อยู่ ยังไม่เป็น recommendation WSDL 2.0 มีความแตกต่างออกไป เช่น ไม่มี tag message แล้ว, เปลี่ยนชื่อ tag port type เป็น interface, มี inheritance (extend)

Data Type and Message ส่วน Data Type เป็นส่วนที่ใช้อธิบาย Data แต่ละ ชนิดที่มีใช้และอ้างอิงถึงใน WSDL การอธิบาย Data Type นั้นจะทำโดยใช้ XML Schema ส่วน Message เป็นการกำหนดชุดของข้อมูลที่ใช้ใน การส่งเป็น Input Parameter และชุดข้อมูลที่ใช้ในการ ตอบกลับของบริการ Web Service

Operation and Port Type ส่วน Operation เป็นการกำหนดชื่อ Operation พร้อม รายละเอียดการส่งข้อมูลนำเข้า Input Message เข้าสู่ การทำงาน และอธิบายผลลัพธ์ที่ได้ว่าเป็น Output Message ใด ส่วน Port type เป็นการจัดกลุ่มของ Operation ที่มีอยู่ ใน Web Service โดยเรียกได้ว่าเป็น Set of Operations ที่ได้รับการจัดรวมกลุ่มเพื่อใช้ในการทำ Binding ต่อไป

Binding, Port and Service ส่วน Binding กำหนดให้กลุ่ม Operation ที่มีอยู่ใน Port Type ใด ๆ สามารถให้บริการผ่านทาง Transport ใดได้บ้าง นั่นหมายถึง Port Type หนึ่ง ๆ สามารถจะให้บริการผ่าน Transport ได้หลายชนิด Transport ใน Web Service มักจะใช้ HTTP ส่วน Port กำหนดตำแหน่ง Address ที่ผู้ใช้บริการจะเข้ามาใช้ บริการจาก Web Service ได้ โดยกำหนด Endpoint Address เข้า กับส่วน Binding ใด ๆ ที่มีอยู่ ส่วน Service เป็นกลุ่มของ Port ที่ระบุ Endpoint Address สำหรับ ให้บริการแล้ว ผู้ใช้บริการ Service Consumer ที่อยู่ภายนอก สามารถอ้างถึง Service นี้ได้

Service Group Service Port Port Port Port Type Port Type Port Type Operation1 Operation1 Operation1 Operation2 Operation2 Operation2 Network Address เป็นแบบ point-to-point Binding … Binding … Binding … Network Address Network Address Network Address Services group operations in the same way that objects or classes group methods

Find | Universal Description, Discovery, and Integration : UDDI Service Registry Provider Requestor Publish Bind Find UDDI SOAP WSDL Find | Universal Description, Discovery, and Integration : UDDI Please see, Overview & Example UDDI Slide For Win!!! 

Universal Description, Discovery, and Integration (UDDI) UDDI สนับสนุนโดย OASIS UDDI มีหน้าที่ในการช่วยค้นหา Web Services และให้ข้อมูลต่าง ๆ ที่จำเป็นต่อผู้ร้องขอ UDDI จะจัดเก็บข้อมูลเชื่อมโยงไปยัง WSDL ของบริการ Web Services ใหม่ ๆ ที่ได้รับการ Register เข้ามา รวมทั้งข้อมูลอื่น ๆ ที่อธิบาย Web Services เพื่อให้บริการค้นหาได้ UDDI ก็คือ Registry ของข้อมูลคำอธิบายเกี่ยวกับ Web Services (Web Services Metadata) นั่นเอง

Public UDDI Public UDDI คือกลุ่มผู้ทำหน้าที่ให้บริการการสืบค้นบริการ Web Services ในเครือข่ายอินเทอร์เน็ต กลุ่มผู้ดูแล Public UDDI IBM Microsoft SAP HP NTT Etc ข้อมูลที่ทำการ Register จะกระจายไปทั่วถึงกันในกลุ่มผู้ดูแล Public UDDI โดยอัตโนมัติ ผู้ใช้ Public UDDI สามารถส่ง SOAP Request ไปร้องขอการค้นหา Web Services ที่ตนต้องการได้จากบริษัทใด ๆ ในกลุ่มผู้ดูแล Public UDDI ปิดตัวลงเพราะการใช้งาน service ในธุรกิจมักเรียก service ที่รู้จักอยู่แล้วหรือเชื่อใจ และพวก service level agreement ต่าง ๆ ยังไม่ mature พอที่จะทำให้ลักษณะของ dynamic discovery มัน work อีกทั้งยังขาดการดูแลจัดการทำให้ข้อมูลที่ register เป็นข้อมูลของเล่นหรือไม่มีจริง ทำให้ลดคุณค่าของ UDDI ไป แต่องค์กรสามารถติดตั้ง private uddi ได้ซึ่งจะดูแลจัดการได้ดีกว่า ต้นปี 2006 IBM, Microsoft, SAP ประกาศปิดไป

UDDI Operators Microsoft UDDI IBM Server UDDI Server HP SAP UDDI UDDI Others UDDI Server

UDDI Information Model <businessEntity> name = xmethods categories = 82101528 contact = xmethods.net <publisherAssertion> name = Australian Import relationship = business partner <businessService> (1..n) name = CurrencyExchangeServiceca tegories = 84121603 <operationalInfo> created = 03/01/04 modified = 05/01/04 <bindingTemplate> (1..n) access point = http://services.xmethods.net:80/soap <tModel> name = CurrencyExchangeModel URL = http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl

Overview Web Service by PHP Informatics BUU. Suranglutch Chaokoksoohng (suranglutch@gmail.com)

Web Service by PHP Must to have PHP PHP NUSOAP Apache server WSDL Editor

PHP NUSOAP สนับสนุน SOAP สามารถ Generate WSDL ได้ ดาวน์โหลดได้ที่ http://sourceforge.net/projects/nusoap/

Server, Test Program For NUSOAP Service อาจกำหนด $debug = 1; เพื่อ Debug error <?php require_once('nusoap.php'); // Pull in the NuSOAP code $server = new soap_server; // Create the server instance $server->register('hello'); // Register the method to expose // Define the method as a PHP function function hello($name) { return 'Hello, ' . $name; } // Use the request to (try to) invoke the service $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ‘ '; $server->service($HTTP_RAW_POST_DATA); ?>

Client, Test Program For NUSOAP Service <?php // Pull in the NuSOAP code require_once('nusoap.php'); // Create the client instance $client = new soapclient('http://localhost/phphack/helloworld.php'); // Call the SOAP method $result = $client->call('hello', array('name' => 'Scott')); // Display the result print_r($result); ?> อาจจะกำหนดบรรทัดต่อไปนี้เพื่อทำ Debugging echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>'; echo '<h2>Response</h2>'; echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';

Debugging on Client Side if ($client->fault) { echo '<p><b>Fault: '; print_r($result); echo '</b></p>'; } else { // Check for errors $err = $client->getError(); if ($err) { // Display the error echo '<p><b>Error: ' . $err . '</b></p>'; // Display the result }

SOAP Request $result = $client->call('hello', array('name' => 'Scott')); POST /phphack/helloworld2.php HTTP/1.0 Host: localhost User-Agent: NuSOAP/0.6.8 (1.81) Content-Type: text/xml; charset=ISO-8859-1 SOAPAction: "" Content-Length: 538 <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd"> <SOAP-ENV:Body> <ns1:hello xmlns:ns1="http://testuri.org"> <name xsi:type="xsd:string">Scott</name> </ns1:hello> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

SOAP Response $server->service($HTTP_RAW_POST_DATA); HTTP/1.1 200 OK Server: Microsoft-IIS/5.0 Date: Wed, 03 Nov 2004 21:32:34 GMT X-Powered-By: ASP.NET X-Powered-By: PHP/4.3.4 Server: NuSOAP Server v0.6.8 X-SOAP-Server: NuSOAP/0.6.8 (1.81) Content-Type: text/xml; charset=ISO-8859-1 Content-Length: 556 <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd"> <SOAP-ENV:Body> <ns1:helloResponse xmlns:ns1="http://tempuri.org"> <return xsi:type="xsd:string">Hello, Scott</return> </helloResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

Web Service by PHP กำหนดตำแหน่งเพื่อเรียกใช้ NUSOAP ใน PHP โดยเลือกกำหนดอย่างใดอย่างหนึ่ง จาก include (‘nusoap.php’); include_once(‘nusoap.php’); require (‘nusoap.php’); require_once (‘nusoap.php’);

Making Service Part สร้าง Server Instant $service = new soap_server; กำหนด WSDL สำหรับการเรียกใช้เซอร์วิส ซึ่ง NUSOAP จะทำการ Generate WSDL ให้เอง $service->configureWSDL(“ชื่อWSDL”, “urnของWSDL”); ลงทะเบียนเซอร์วิสกับ SOAP Server ทำการสร้างฟังก์ชั่นเพื่อให้บริการ กำหนดการส่งข้อมูลกลับไปยัง Client $service->service(HTTP_RAW_POST_DATA); NUSOAP API ดูได้ที่ http://dietrich.ganx4.com/nusoap/APIDoc/ Tuturial: http://www.scottnichol.com/nusoapprogwsdl.htm

Example: Web Service in restaurant Server รับประเภทอาหาร ส่งรายการอาหาร HTML Form User เลือก ประเภทอาหาร Client รับประเภทอาหาร 2 Call getFoodName() 1 แสดงรายการอาหาร CateringService.php CateringServiceClient.php

Catering Service Coding <?php // Pull in the NuSOAP code require('../lib/nusoap.php'); // Create the server instance $server = new soap_server(); // Initialize WSDL support $server->configureWSDL('CateringService', 'urn:CateringServiceWsdl'); // กำหนด Type ต่าง ๆ ใน WSDL ….. $server-> register('getFoodName', // method name array('typefood' => 'xsd:string'), // input parameters array('food' => 'tns:foodnameArray'), // output parameters กำหนดใน SOAP 'urn:CateringServiceWsdl', // namespace 'urn:CateringServiceWsdl#getFoodName', // SOAPAction 'rpc', // style 'encoded', // use 'cateringbufService') ;

Catering Service Coding (con.2) function getfoodName($typefood){ $food=array(); // อาจจะมีการติดต่อฐานข้อมูลก็ได้ … return $food; } // Use the request to (try to) invoke the service $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; // ส่งผลลัพธ์กลับไปยัง Client program $server->service($HTTP_RAW_POST_DATA); php?>

Catering Service Coding (con.3) การกำหนด ComplexType สำหรับ Output message Output message ของโปรแกรม Server Output message ของ SOAP $server->wsdl->addComplexType( 'fooddetail', 'complexType', 'struct', 'all', '', array( 'foodname' => array('name'=>'foodname','type'=>'xsd:string'), ) );

Catering Service Coding (con.4) การกำหนด ComplexType สำหรับ Output message $server->wsdl->addComplexType( 'foodnameArray', //name of output variable 'complexType', 'array', ' ', 'SOAP-ENC:Array', array(), array( array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:fooddetail[]') // Array foodname µÒÁ·Õè»ÃСÒÈäÇé¢éÒ§º¹ ), 'tns:fooddetail' );

ComplexType ตัวอย่าง ComplexType ที่มีหลาย Element $server->wsdl->addComplexType( 'Person', 'complexType', 'struct', 'all', '', array( 'firstname' => array('name' => 'firstname', 'type' => 'xsd:string'), 'age' => array('name' => 'age', 'type' => 'xsd:int'), 'gender' => array('name' => 'gender', 'type' => 'xsd:string') ) ); Output message function listAllPersons(Input_Message) { $pvar[0] = array (‘firstname’ => ‘Nid’, ‘age’=> 23, ‘gender’ =>’Female’); $pvar[1] = array (‘firstname’ => ‘Dang’, ‘age’=> 22, ‘gender’ =>’Female’); … return $pvar; } จะ Bind ไปยัง Output message

Catering Service Client Coding <?php if(!isset($_GET["typefood"])){ //กำหนด ฟอร์มเพื่อให้ User ทำการเลือกประเภทอาหาร // ส่วนนี้อาจจะไม่มีก็ได้หาก Client ไม่จำเป็นต้องทำการติดต่อกับ User }else{ //ส่วนนี้เป็นการเรียกไปยัง Service require('../lib/nusoap.php'); $s = new soapclient('http://localhost/phpservice/samples/CateringService.php'); $result = $s ->call('getFoodName',$_GET["typefood"]); //แสดงผลลัพธ์ } ?>

Calling Service by WSDL //Set proxy $client = new soapclient('GoogleSearch.wsdl', true, $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } $client->soap_defencoding = 'UTF-8'; // Set $params …. $result = $client->call('doGoogleSearch', $params);

References…and other great links! how soap works http://www-106.ibm.com/developerworks/library/ws-peer3/ Index for articles and various SOAP related resources. http://www.perfectxml.com/soaptutor.asp Older soap specification SOAP: Simple Object Access Protocol http://static.userland.com/xmlRpcCom/soap/SOAPv11.htm soap primer http://discuss.develop.com/archives/wa.exe?A2=ind0007&L=soap&F=&S=&P=9777 soap school http://www.w3schools.com/SOAP/default.asp Topics in Software Engineering, Web Infrastructure, Services, and Applications, Jill.Kerschbaum@cs.colorado.edu understanding soap http://softwaredev.earthweb.com/article/0,,10455_641321,00.html W3C SOAP http://www.w3.org/TR/soap12/ W3c SOAP notes http://www.w3.org/TR/SOAP/