Presentation is loading. Please wait.

Presentation is loading. Please wait.

2007/10/30 최석훈. 목차 I. Distributed System II. SOAP 의 장점 III. SOAP 메시지 구조 I. Envelope II. Header III. Body IV. SOAP 예제 – 달력 얻기 I. SOAP server II. SOAP client.

Similar presentations


Presentation on theme: "2007/10/30 최석훈. 목차 I. Distributed System II. SOAP 의 장점 III. SOAP 메시지 구조 I. Envelope II. Header III. Body IV. SOAP 예제 – 달력 얻기 I. SOAP server II. SOAP client."— Presentation transcript:

1 2007/10/30 최석훈

2 목차 I. Distributed System II. SOAP 의 장점 III. SOAP 메시지 구조 I. Envelope II. Header III. Body IV. SOAP 예제 – 달력 얻기 I. SOAP server II. SOAP client III. Fault element

3 Distributed System JAVA RMI CORBA DCOM 특정 포트 사용으로 방화벽에서 차단될 수 있음 일반적으로 위 기술 간 호출 불가능 특정 포트 사용으로 방화벽에서 차단될 수 있음 일반적으로 위 기술 간 호출 불가능 여러 서버에 분산된 컴포넌트간 상호 호출 가능

4 SOAP 의 장점 플랫폼 독립적 인간 친화적 플랫폼 및 언어에 종속되지 않고 쉽게 구현 및 사용 가능 방화벽 등의 방해 없이 거의 모든 시스템과 통신 가능 비동기식 처리로 한 방향 액션 ( 퍼블리싱 등 ) 처리 유용 XML 기반 SMTP 사용 HTTP 사용

5 SOAP 메시지 구조 … …

6 Envelope

7 Envelope element 루트 엘리먼트 SOAP 메시지의 네임스페이스를 지정 http://schemas.xmlsoap.org/soap/envelope/ http://www.w3.org/2003/05/soap-envelope/ encodingStyle attribute 어떤 식으로 메시지를 구성할 것인지 명시 http://schemas.xmlsoap.org/soap/encoding/ http://www.w3.org/2003/05/soap-encoding

8 Header

9 Header element Header 의 사용은 선택 사항 SOAP 메시지를 받는 쪽에서 이를 어떻게 처리할 것 인지를 기술 여러 개의 자식 엘리먼트를 포함할 수 있음 받는 쪽에서는 해석 가능한 Header 의 자식 엘리먼트만 해석해 수행 mustUnderstand 속성이 1 로 설정되어 있으면 반드시 해석해야 하고, 못하면 에러를 발생해야 함

10 Header element actor attribute (role attribute in SOAP 1.2) 해당 헤더를 어떤 수신자가 처리할 것인지 기술 <au:Authentication xmlns:au="http://..." en:actor="http://actor.com/auth" en:mustUnderstand="1"> foo 1q2w3e … Gildong, Hong. …

11 Body

12 Body element 메시지 수신자에게 전달되어야 할 목적 정보 프로시저 요청 / 실행 결과 / 에러 등을 포함 최종 수신자가 정의한 네임스페이스를 써서 기술 WSDL SOAP:Body …

13 SOAP 예제 – 달력 얻기

14 SOAP 서버 1. #!/usr/bin/env python 2. 3. import sys, calendar 4. 5. #Import the SOAP.py machinery 6. from SOAPpy import SOAP 7. 8. CAL_NS = "http://uche.ogbuji.net/eg/ws/simple-cal" 9. 10. class Calendar: 11. def getMonth(self, year, month): 12. return calendar.month(year, month) 13. 14. def getYear(self, year): 15. return calendar.calendar(year) 16. 17. server = SOAP.SOAPServer(("localhost", 8080)) 18. cal = Calendar() 19. server.registerObject(cal, CAL_NS) 20. 21. print "Starting server..." 22. server.serve_forever()

15 SOAP 클라이언트 1. import sys, httplib 2. 3. SERVER_ADDR = '127.0.0.1' 4. SERVER_PORT = 8080 5. CAL_NS = "http://uche.ogbuji.net/ws/eg/simple-cal" 6. 7. BODY_TEMPLATE = """<SOAP-ENV:Envelope 8. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 9. xmlns:s="http://uche.ogbuji.net/eg/ws/simple-cal" 10. xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 11. xmlns:xsd="http://www.w3.org/1999/XMLSchema" 12. SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 13. 14. 15. %s 16. %s 17. 18. 19. """

16 SOAP 클라이언트 ( 계속 ) 20. def GetMonth(): 21. year = 2001 22. month = 12 23. body = BODY_TEMPLATE % (year, month) 24. 25. blen = len(body) 26. requestor = httplib.HTTP(SERVER_ADDR, SERVER_PORT) 27. requestor.putrequest("POST", "cal-server") 28. requestor.putheader("Host", SERVER_ADDR) 29. requestor.putheader("Content-Type", "text/plain; charset=\"utf-8\"") 30. requestor.putheader("Content-Length", str(blen)) 31. requestor.putheader("SOAPAction", "http://uche.ogbuji.net/eg/ws/simple-cal") 32. requestor.endheaders() 33. 34. print 'SENDED MESSAGE---' 35. print body 36. print '-----------------\n' 37. 38. requestor.send(body)

17 SOAP 클라이언트 ( 계속 )

18 HTTP headers Accept Specifies which Internet media types are acceptable Content-Length Indicates the size (in octets) of the entity-body Content-Type Specifies the Internet media type of the entity-body Host Specifies the Internet host and port number User-Agent Contains information about the user agent (client) SOAPAction URI or empty string("") or NULL

19 SOAP 클라이언트 ( 계속 ) 20. def GetMonth(): 21. year = 2001 22. month = 12 23. body = BODY_TEMPLATE % (year, month) 24. 25. blen = len(body) 26. requestor = httplib.HTTP(SERVER_ADDR, SERVER_PORT) 27. requestor.putrequest("POST", "cal-server") 28. requestor.putheader("Host", SERVER_ADDR) 29. requestor.putheader("Content-Type", "text/xml; charset=\"utf-8\"") 30. requestor.putheader("Content-Length", str(blen)) 31. requestor.putheader("SOAPAction", "http://uche.ogbuji.net/eg/ws/simple-cal") 32. requestor.endheaders() 33. 34. print 'SENDED MESSAGE---' 35. print body 36. print '-----------------\n' 37. 38. requestor.send(body)

20 SOAP 클라이언트 ( 계속 ) 39. (status_code, message, reply_headers) = requestor.getreply() 40. 41. reply_body = requestor.getfile().read() 42. 43. print 'RECEIVED MESSAGE---' 44. print "status code:", status_code 45. print "status message:", message 46. print "HTTP reply header:" 47. for header in reply_headers.headers: 48. print header, 49. print "HTTP reply body:\n", reply_body 50. print '-------------------' 51. 52. if __name__ == "__main__": 53. GetMonth()

21 HTTP status code Successful 2xx 200 – OK / 204 – No Content Redirection 3xx 301 – Moved Permanently / 302 – Found Client Error 4xx 400 – Bad Request / 403 – Forbidden / 404 – Not Found Server Error 5xx 500 – Internal Server Error / 503 – Service Unavailable

22 SOAP 클라이언트 ( 계속 )

23 Fault

24 Fault element SOAP 메시지 처리 때 생기는 에러 정보를 처리 엘리먼트 안에 하나만 나타날 수 있음 다음 엘리먼트를 가질 수 있음 - 오류 코드 - 오류 설명 - 누가 오류를 발생시켰는지에 대한 정보 - 오류에 대한 자세한 설명

25 SOAP fault

26 Reference / Q&A 석광진 외 역, 자바를 이용한 웹 서비스 구축. 안진만 역,.NET XML 웹 서비스. 김종민 외 저, POWER XML. 송은지 외 저, 웹 서비스 컴퓨팅. Quick reference to HTTP headers The Python Web services developer: Python SOAP l ibraries The Python Web services developer: Python SOAP l ibraries SOAP Version 1.2 Part 1: Messaging Framework (S econd Edition) SOAP Version 1.2 Part 1: Messaging Framework (S econd Edition) images from gettyimages RF sectiongettyimages


Download ppt "2007/10/30 최석훈. 목차 I. Distributed System II. SOAP 의 장점 III. SOAP 메시지 구조 I. Envelope II. Header III. Body IV. SOAP 예제 – 달력 얻기 I. SOAP server II. SOAP client."

Similar presentations


Ads by Google