Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data 전송하는 웹 서비스 Meilan JIANG Cyber infrastructure Research Laboratory Department of Advanced Technology Fusion.

Similar presentations


Presentation on theme: "Data 전송하는 웹 서비스 Meilan JIANG Cyber infrastructure Research Laboratory Department of Advanced Technology Fusion."— Presentation transcript:

1 Data 전송하는 웹 서비스 Meilan JIANG (meelankang@gmail.com)meelankang@gmail.com Cyber infrastructure Research Laboratory Department of Advanced Technology Fusion Konkuk University

2 목차 문서 - 스타일 SOAP 프로그래밍 – 클라이언트와 웹 서비스 간의 데이터 교환은 문서 스타일의 SOAP 문서로 이루어진다 Remote Procedure Call 과 Document- style SOAP 의 차이점 –RPC- 스타일 SOAP 에서는 Java classes (methods) 가 호출된다 – 문서 - 스타일 SOAP 에서는 XML 문서를 전송하 고 XML 문서를 받는다

3 문서 - 스타일 웹 서비스

4 Creatio n 문서 - 스타일 웹 서비스 XML 문서를 직접 다루도록 디자인되었다 –XML 문서를 입력으로 받는다 –XML 문서를 출력으로 생성한다 Web Service Client Web Service XML Document as input Parsing XML Document as input Parsing XML Document as output Creatio n XML Document as output SOAP DOM

5 웹 서비스 클라이언트 DOM 이나 SAX 파서를 사용하여 Java object 로부터 XML 문서를 생성 웹 서비스에 XML 문서를 전송 ( 요청 ) 웹 서비스로부터 XML 문서를 수락 ( 응답 ) XML 문서를 처리하고 DOM 이나 SAX 파서 를 사용하여 java object 를 생성

6 웹 서비스 Client 로부터 XML 문서를 수락 XML 문서를 처리하고 DOM 이나 SAX 파서 를 사용하여 java object 를 생성 Client 요청을 처리 (Java 실행 ) DOM 이나 SAX 파서를 사용하여 Java object 로부터 XML 문서를 생성 클라이언트에 XML 문서를 전송 ( 응답 )

7 Java SOAP 통신 모델 (Diagram) Web Service Client Web Service in Java SOAP Engine SOAP Request Java Call Java Response SOAP Response SOAP API

8 Java SOAP 통신 모델 (Diagram) 웹 서비스 client XML 형식의 SOAP 요청을 생성한 후 SOAP API 를 통하여 SOAP 엔진 에 전송 SOAP 엔진은 SOAP 요청을 java 호출로 변환하여 웹 서비스 실행 웹 서비스는 java 응답을 반환 SOAP 엔진은 java 응답을 SOAP 응답 메 시지로 변환하여 client 에 전송

9 웹 서비스 호출 SOAP 요청 SOAP 응답 Java 호출 Java 응답

10 RPC- 스타일 SOAP

11 Web Servic e Client (RPC) SOAP Engine RPC- 스타일 SOAP 호출 Java Object SOAP Envelope SOAP Envelope Serialization Java Object De-Serialization SOAP Envelope SOAP Envelope 웹 서비스 client 는 XML 형식의 SOAP 요청을 생성한 후 SOAP API 를 통하여 SOAP 엔진에 전송

12 “Common” Java 호출 public class HelloWorld { // Returns "Hello !". public static String sayHello(String sender) { return "Hello " + sender + "!"; } public class HelloWorldClient { public static void main(String args[]) { System.out.println("HelloWorld.main: Entering..."); HelloWorld.sayHello(“Reader”); System.out.println(“HelloWorld.main: Leaving…”); }

13 SOAP API 를 사용한 Client public class HelloWorldClient { public static void main(String args[]) { System.out.println("HelloWorld.main: Entering..."); try { String url = "http://localhost:8080/HelloWorld.jws"; String sender = "Reader"; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new URL(url)); call.setSOAPActionURI("sayHello"); call.setEncodingStyle(NamespaceConstants.NSURI_SOAP_ENCODING); call.setOperationName(new QName("urn:helloworld", "sayHello")); //call.setReturnType(XMLType.XSD_STRING); String hello = (String)call.invoke(new Object[] { sender } );

14 XML 형식의 SOAP Envelope <SOAP-ENV:Envelope … xmlns:SOAP-ENV=“http://schema......> Reader sayHello(“Reader”);

15 RPC- 스타일 SOAP Client SOAP API 를 사용하여 Java calls 에 대한 직렬화를 통해 XML 문서 생성 SOAP API 를 사용하여 SOAP envelope 생 성 HTTP protocol 에 의해 SOAP envelope 로 부터 SOAP 요청을 생성 SOAP 요청을 SOAP 엔진에 전송

16 SOAP 요청 / 응답 SOAP 엔진 (client) SOAP 엔진 (server) SOAP 요청 SOAP Envelope in HTTP document SOAP Envelope in HTTP document SOAP 응답 SOAP Envelope in HTTP document SOAP Envelope in HTTP document

17 SOAP 응답 / 요청 -HTTP 문서 POST /HelloWorld.jws HTTP/1.0 Content-Type: text/xml; charset=utf Accept: application/soap+xml, ….. User-Agent: Axis/1.4 Host: 127.0.0.1:8081 SOAPAction: “sayHello” Content-Length: 494 <SOAP-ENV:Envelope … xmlns:SOAP-ENV=“http://schema......>

18 SOAP Engine Web Servic e (RPC) RPC- 스타일 SOAP 통신 Java Object SOAP Envelope SOAP Envelope De-Serialization Java Object Serialization SOAP Envelope SOAP Envelope

19 HelloWorld Client [1] SOAP CALL [8]SOAP Response [4]Java Call [5]Java String tcpmon [3]SOAP CALL [6]SOAP Response tcpmon GUI [2]SOAP CALL[71SOAPCALL AXIS Server HelloWorld Class

20 문서 - 스타일 SOAP

21 Web Servic e Client SOAP 엔진 문서 - 스타일 SOAP 호출 SOAP Envelope XML 문서 (input) XML 문서 (input) XML 문서 (input) XML 문서 (input) XML 문서 (output) XML 문서 (output) XML 문서 (output) XML 문서 (output)

22 문서 - 스타일 Client 사용자가 DOM 이나 SAX 를 사용하여 XML 문 서를 생성 사용자가 SOAP API 를 사용하여 XML 문서를 SOAP Body 에 포함하는 SOAP envelope 생 성 SAOP envelop 를 SOAP 엔진에 전송 SOAP 엔진으로부터 SOAP envelope 를 수락, DOM 이나 SAX 를 사용하여 XML 문서를 SOAP envelope 로부터 추출

23 SOAP 요청 / 응답 (the same for both) SOAP Engine (client) SOAP Engine (server) SOAP Request SOAP Envelope in HTTP document SOAP Envelope in HTTP document XML Document (input) XML Document (input) SOAP Response SOAP Envelope in HTTP document SOAP Envelope in HTTP document XML Document (input) XML Document (input)

24 SOAP 엔진 웹 서비스 문서 - 스타일 웹 서비스 호출 SOAP Envelope XML 문서 (input) XML 문서 (input) XML 문서 (input) XML 문서 (input) XML 문서 (output) XML 문서 (output) XML 문서 (output) XML 문서 (output)

25 RPC- 스타일과 문서 - 스타일의 차이점

26 주요 차이점 Serialization & De-serialization – 문서 스타일 SOAP 에서, client 는 웹 서비스 호출을 Java method 호출로 인식하지 않는다 –RPC 스타일 SOAP 에서, SOAP 엔진은 java objects 와 XML 문서간의 변환 작업을 수행한다 Programming Semantic –RPC 스타일 SOAP 에서, client 와 서버는 잘 정의 되 프로그래밍 모델로 만들어져야 한다 – 문서 스타일 SOAP 에서, XML 문서가 정의되고 각 각의 Element 에 대한 의미는 client 와 서버가 해석 해야 한다

27 RPC 스타일 Java 호출 public class HelloWorld { // Returns "Hello !". public static String sayHello(String sender) { return "Hello " + sender + "!"; } public class HelloWorldClient { public static void main(String args[]) { System.out.println("HelloWorld.main: Entering..."); HelloWorld.sayHello(“Reader”); System.out.println(“HelloWorld.main: Leaving…”); }

28 RPC- 스타일 웹 서비스 Client public class HelloWorldClient { public static void main(String args[]) { System.out.println("HelloWorld.main: Entering..."); try { String url = "http://localhost:8080/HelloWorld.jws"; String sender = "Reader"; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new URL(url)); call.setSOAPActionURI("sayHello"); call.setEncodingStyle(NamespaceConstants.NSURI_SOAP_ENCODING); call.setOperationName(new QName("urn:helloworld", "sayHello")); //call.setReturnType(XMLType.XSD_STRING); String hello = (String)call.invoke(new Object[] { sender } ); SOAP API

29 SOAP Envelope <SOAP-ENV:Envelope … xmlns:SOAP-ENV=“http://schema......> Reader

30 기타 차이점 독립성. 문서 - 스타일 SOAP 에서, reliance on the SOAP engine is minimized –No need for serialization/de-serialization and –No concern for programming model 효율성. applications using document-style SOAP vs. those using RPC-style SOAP –Document-style SOAP applications may also need transformation between java data and XML document

31 문서 - 스타일과 RPC- 스타일 문서 - 스타일 SOAP – 일반 데이터나 XML 데이터에 대한 데이터 교 환에 사용 – 데이터 변형 어플리케이션에 사용 E.g. XSLT. RPC- 스타일 SOAP –Method 호출 어플리케이션. – 기존의 java classes 를 웹 서비스로 활용하고 자 하는 경우 사용

32 Document-Style SOAP Application Example: Web Service Deployment Descriptor

33 Manual/Custom Deployment Automatic Deployment –Source code is available to everybody –Source code must be in the JWS files, or the JAR files must be manually copied to the lib directory –The amount of configuration required is limited Manual/Custom Deployment –Prepare Compiled Java classes & Deployment Descriptor (XML document) –Submit deployment descriptor (WSDD) to AdminService (web service) by AdminClient in Axis

34 Web Service Deployment Descriptor Deployment descriptor: StockQuote.wsdd <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <parameter name="className" value="com.wrox.jws.stockquote.StockQuote"/>

35 Custom Deployment in Document-style SOAP AdminClient AdminServic e SOAP Engine SOAP Request Java Call Java Response SOAP Response XML Document (WSDD) XML Document (WSDD) XML Document (WSDD) XML Document (WSDD) XML Document (WSDD) XML Document (WSDD) XML Document (WSDD) XML Document (WSDD)

36 SOAP Request for WSDD POST /axis/services/AdminService HTTP/1.0 Content-Length: 587 Host: localhost Content-Type: text/xml; charset=utf-8 SOAPAction: “AdminService” <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <parameter name="className" value="com.wrox.jws.stockquote.StockQuote"/>

37 Creatio n Document-style Web Services Designed to handle XML documents –Receive XML documents as an input –Produce XML documents as an output Web Service Client Web Service XML Document as input Parsing XML Document as input Parsing XML Document as output Creatio n XML Document as output SOAP DOM


Download ppt "Data 전송하는 웹 서비스 Meilan JIANG Cyber infrastructure Research Laboratory Department of Advanced Technology Fusion."

Similar presentations


Ads by Google