The Cricket Location

Download Report

Transcript The Cricket Location

Beginning 자바 웹 서비스
SOAP
강미란([email protected])
Cyber-Infrastructure Research Lab
Konkuk University
목차
1.
2.
3.
4.
5.
SOAP이란?
SOAP의 용도?
장점 & 단점
SOAP 메시지 교환 모델
SOAP 메시지 구조
SOAP
• SOAP은 컴퓨터 네트워크 상에서 XML 기반의 메시지
교환을 위한 프로토콜이다
– HTTP/HTTPS 사용
– 'Simple Object Access Protocol'
• SOAP 은 애플리케이션이 HTTP를 통해 정보를 교환
할 수 있게 하는 심플한 XML 기반의 프로토콜이다.
• SOAP 이란 무엇인가, SOAP에서 애플리케이션 사이
에서 정보를 교환하기 위해 XML이 어떤 역할을 하는
가?
• SOAP 을 위한 XML and XML Namespaces
SOAP 이란?
•
•
•
•
•
•
•
•
•
•
SOAP
SOAP
SOAP
SOAP
SOAP
SOAP
SOAP
SOAP
SOAP
SOAP
is a communication protocol
is for communication between applications
is a format for sending messages
is designed to communicate via Internet
is platform independent
is language independent
is based on XML
is simple and extensible
allows you to get around firewalls
will be developed as a W3C standard
SOAP은 어디에 사용?
메시지 경로
왜 SOAP 사용?
 애플리케이션 개발할 경우, 프로그램간의 인터넷 커뮤니케이
션(交流)을 가능하게 하는 것은 매우 중요하다
 오늘날 애플리케이션 간의 통신은 DCOM 이나 CORBA 와 같
이 오브젝트간의 Remote Procedure Calls (RPC) 를 통해 이루
어 진다. HTTP는 이런 용도로 디자인된 것이 아니다.
 RPC는 호환성과 보안성의 문제를 갖고 있다. 방화벽이나 프
록시 서버는 보통 RPC 호출을 차단하고 있다.
 애플리케이션 간의 보다 효율적인 통신은 HTTP를 통해 이루
어진다. HTTP는 모든 인터넷 브라우저와 서버에서 지원하고
있다.
 SOAP 의 목표
 SOAP은 서로 다른 운영체제에서 실행되는 서로 다른 기술과 프
로그래밍 언어를 사용하는 애플리케이션간의 통신을 지원하기
위한 것이다.
6
장점
 프록시 와 방화벽을 통과하는 간편한 통신방법
◦ HTTP 사용
 다양한 전송 프로토콜 허용
◦ JMS,SMTP,RSS etc..
 SOAP 은 플랫폼 독립적이다.
 SOAP 은 언어 독립적이다.
 SOAP 은 가벼운 프로토콜이다.
◦ 텍스트-기반의 메시지
 SOAP 은 심플하고 확장 가능하다.
◦ XML 구조
 SOAP 은 벤더 중립적이다.
◦ Sun, IBM, Microsoft
단점
 XML 포맷은 기존 Object App보다 느리다
◦ When we transfer small size messages, it is fine.
◦ 보안 메커니즘이 부족하다
◦ SOAP 은 메시지를 처리하기 전에 인증 절차가 따로
없다
◦ SOAP 은 어떠한 암호화 매커니즘도 갖고 있지 않다
◦ SOAP 메시지 전송의 성공여부를 보장할 수 없다
 Ex. System crash happens.
 Publish/Subscribe 모델에 대한 지원이 부족하다
◦ SOAP 클라이언트는 서버에 직접 요청을 전송해야 한
다.
SOAP 메시지 교환 모델
• Simple message transfer model
4.SOAP message exchange
model
Message Chain topologies
◦ Request/Response Model
Sender
◦ Recursive Model
Request SOAP Message
Response SOAP Message
Endpoint(A)
Sender
Endpoint C
Endpoint A
Endpoint B
◦ Broadcast Model
Sender
Endpoint C
Endpoint A
Endpoint B
SOAP 메시지 구조
• SOAP 메시지는 아래와 같은 Element를 포함
하는 일반적인 XML 문서이다
– A required Envelope element
• XML 문서가 SOAP 메시지임을 나타낸다
– An optional Header element
• 헤더 정보를 포함한다
– A required Body element
• 호출과 응답 정보를 포함한다
– An optional Fault element
• 메시지 처리 과정에 발생하는 오류에 대한 정보를 포함
한다
SOAP 메시지 구조
• 모든 element는 “default namespace for
the SOAP envelope”에 기술되어 있다:
– http://www.w3.org/2001/12/soap-envelope
• default namespace for SOAP encoding
and data types is:
– http://www.w3.org/2001/12/soap-encoding
12
SOAP 메시지 구조
• SOAP 메시지
SOAP 메시지 구조
• 문법적인 규칙
– SOAP 메시지는 MUST
• be encoded using XML
• use the SOAP Envelope namespace
• use the SOAP Encoding namespace
– SOAP 메시지는 MUST NOT
• contain a DTD reference
• contain XML Processing Instructions
SOAP Envelop Element I
 The SOAP Envelope Element
◦ 정의
 Envelope element 는 SOAP 메시지의 root element 이다
 특정 구조의 XML 문서를 SOAP 메시지라고 한다
◦ xmlns:soap 네임스페이스
 must always have an Envelope element associated with the "
http://www.w3.org/2001/12/soap-envelope" namespace.
 다른 namespace 를 사용하면 애플리케이션은 메시지를 버리거
나 오류를 발생하게 된다
◦ encodingStyle 속성
 문서에서 사용되는 data types 을 정의한다
 SOAP element 내 임의 element 에서나 사용 가능하다
 해당 element의 내용 과 모든 하위 elements에 적용된다
 SOAP 메시지는 default encoding이 없다
SOAP Envelop Element II
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap=“http://www.w3.org/2001/12/soap-envelope”
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
...
Message information goes here
...
</soap:Envelope>
16
SOAP Header Element I
 SOAP Header Element
◦ Optional
◦ 애플리케이션 특유(application specific)의 정보를 포함한다
 Ex. authentication, payment, etc.
◦ Header element가 존재한다면
 이는 Envelope element의 첫 하위 element 여야 한다
 기본 namespace의 세가지 속성
◦ Actor
 메시지를 처리할 endpoint를 알려준다
◦ mustUnderstand
 기본 값 0
 1, 수신자는 반드시 element를 인지하여야 하며, 그렇지 않은 경우
fail 오류 발생한다
◦ encodingStyle
SOAP Header Element II
<?xml version="1.0"?>
<soap:Envelope xmlns:soap=“http://www.w3.org/2001/12/soapenvelope”
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Header>
<m:Trans
xmlns:m=“http://www.w3schools.com/transaction/”
soap:mustUnderstand="1">234</m:Trans>
</soap:Header>
...
...
</soap:Envelope>
18
SOAP Header Element III
• 위의 예제는 "Trans" element를 포함한 헤더를 갖
고 있다. 속성
– mustUnderstand– 1,
– value -234
• SOAP 은 기본 namespace에 세가지 속성을 정의
하고 있다 ("http://www.w3.org/2001/12/soapenvelope")
• 세가지 속성
– actor, mustUnderstand, encodingStyle
• SOAP Header에 정의된 속성은 SOAP message 수
신자가 메시지 처리하는 방법을 나타낸다
The actor Attribute I
• SOAP 메시지는 메시지 path 내에 있는 여러
endpoint를 통과하며 송신자로부터 수신자로
전송된다
• SOAP message의 모든 부분이 최종
endpoint를 위한 것은 아니며, 메시지 path
내에 하나 혹은 여러 개 endpoint를 위한 내
용일 수 있다.
• SOAP actor 속성은 헤더 element를 개개
endpoint에 보내는 용도로 사용할 수 있다
• soap:actor="URI"
The actor Attribute II
<?xml version="1.0"?>
<soap:Envelope xmlns:soap=“http://www.w3.org/2001/12/soapenvelope”
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Header>
<m:Trans
xmlns:m=“http://www.w3schools.com/transaction/”
soap:actor="http://www.w3schools.com/appml/">
234
</m:Trans>
</soap:Header>
...
...
</soap:Envelope>
The mustUnderstand Attribute I
• SOAP mustUnderstand 속성
– 헤더 entry 가 수신자 측에서의 처리가 필수인
지 아니면 옵션인지를 나타내는데 사용된다
– Header element 하위 Element에서
"mustUnderstand="1” 이면 수신자는 반드시
해당 Element를 인지하고 있어야 함을 나타낸
다
– 수신자가 해당 Element를 알지 못하면
Header를 처리할때 오류를 발생하게 된다
• soap:mustUnderstand="0|1"
The mustUnderstand Attribute II
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap=“http://www.w3.org/2001/12/soap-envelope”
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Header>
<m:Trans xmlns:m="http://www.w3schools.com/transaction/“
soap:mustUnderstand="1">
234
</m:Trans>
</soap:Header>
...
...
</soap:Envelope>
The SOAP Body Element I
 필수 요소로서의 SOAP Body element 는 실
질적인 SOAP 메시지를 포함한다
 SOAP Body element는 최종 endpoint를 위
한 내용이다
 SOAP Body element 의 하위 Element는
namespace-qualified Element일 수 있다
 SOAP 기본 namespace를 갖는 Body
element에서는 하나의 Element를 정의한다
("http://www.w3.org/2001/12/soapenvelope")
24
The SOAP Body Element II
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope“
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body>
<m:GetPrice xmlns:m="http://www.w3schools.com/prices">
<m:Item>Apples</m:Item>
</m:GetPrice>
</soap:Body>
</soap:Envelope>
The SOAP Body Element III
• 위의 예제는 사과 가격을 요청하는 예제이
다
• m:GetPrice와 Item element는
application-specific element이다
• 이런 Element는 SOAP standard는 아니다
The SOAP Body Element VI
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope“
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body>
<m:GetPriceResponse
xmlns:m="http://www.w3schools.com/prices">
<m:Price>1.90</m:Price>
</m:GetPriceResponse>
</soap:Body>
</soap:Envelope>
The SOAP Fault Element I
• SOAP message에서의 오류 메시지는
Fault element에 포함된다
• Fault element가 존재한다면, Body
element의 하위 Element로 나타난다
• Fault element는 SOAP message에서 한번
만 나타난다
The SOAP Fault Element II
• Fault element의 하위 Element
Sub Element
Description
<faultcode>
오류를 식별할 수 있는 코드
<faultstring>
사람이 해독 가능한 오류에 대한 설명
<faultactor>
오류를 발생시킨 SOAP 노드를 나타낸다
<detail>
Body element와 관련되는 자세한 오류 정보
SOAP Fault Codes
• The faultcode values defined below must be used
in the faultcode element when describing faults
Error
Description
VersionMismatch
Found an invalid namespace for the SOAP
Envelope element
MustUnderstand
An immediate 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 proceed
6. Summary
1. SOAP은
인터넷에서 메시지를 교환하기 위한 경량의 프로토
콜이다
2. SOAP은
인터넷 상에서 쉽게 구현할 수 있다
호환성이 있다
3. 장점 & 단점
4. SOAP 메시지 교환 모델
5. SOAP 메시지 구조