Upload
austin-hancock
View
227
Download
2
Embed Size (px)
Citation preview
18 장 Data Transmission
2001.11.19
인공지능 연구실홍 정 연
Contents Executing a Data Transmission How can XML help? SOAP Transmission Over HTTP
Executing a Data Transmission
Agree on a Format Transport Routing Request-Response Processing
How can XML help? XML Documents are Self-
Documenting Element 나 attribute 의 이름이 contents
를 표현 다른 document 의 supporting 없이
명확하게 문서를 표현
<?xml version="1.0"?><!DOCTYPE OrderData [ <!ELEMENT OrderData (Invoice+)> <!ELEMENT Invoice (Customer, Part+)> <!ATTLIST Invoice orderDate CDATA #REQUIRED shipDate CDATA #REQUIRED><!ELEMENT Customer EMPTY><!ATTLIST Customer name CDATA #REQUIRED address CDATA #REQUIRED city CDATA #REQUIRED state CDATA #REQUIRED postalCode CDATA #REQUIRED><!ELEMENT Part EMPTY><!ATTLIST Part description CDATA #REQUIRED quantity CDATA #REQUIRED price CDATA #REQUIRED>]>
<OrderData> <Invoice orderDate="10/17/2000" shipDate="10/20/2000"> <Customer name="Homer J. Simpson" address="742 Evergreen Terrace" city="Springfield" state="KY" postalCode="12345" /><Part description="2 inch blue grommets" quantity="17" price="0.10" /> <Part description="3 inch red sprockets" quantity="11" price="0.15" /> </Invoice> <Invoice orderDate="10/21/2000" shipDate="10/25/2000"> <Customer name="Kevin B. Williams" address="744 Evergreen Terrace" city="Springfield" state="KY" postalCode="12345" /> <Part description="1.5 inch silver sprockets" quantity="9" price="0.25" /> <Part description="0.5 inch gold widgets" quantity="3" price="0.35" /> </Invoice></OrderData>
How can XML help? XML Documents are Flexible
현재 코드의 변형 없이 information 을 추가 하는 것이 쉬움
<?xml version="1.0"?><!DOCTYPE OrderData [ <!ELEMENT OrderData (Invoice+)> <!ELEMENT Invoice (Customer, Part+)> <!ATTLIST Invoice orderDate CDATA #REQUIRED shipDate CDATA #REQUIRED> shiplMethod (USPS | UPS | FedEx) #IMPLIED><!ELEMENT Customer EMPTY>
How can XML help? XML Documents are
Normalized XML Documents can Utilize
Off-The-Shelf XML Tools Off-the-shelf XML tools ; XML document 의 creation,
manipulation, processing 에 적합
How can XML help? Routing and Requesting
기존의 문서를 추가적인 parent element로 wrapping 하여 문서가 어떻게 process되고 route 되는지를 describe 할 수 있음
envelope<!ELEMENT OrderData (Invoice+)><!ELEMENT Invoice (Customer, Part+)><!ATTLIST Invoice orderDate CDATA #REQUIRED shipDate CDATA #REQUIRED><!ELEMENT Customer EMPTY><!ATTLIST Customer name CDATA #REQUIRED address CDATA #REQUIRED …..
<!ELEMENT OrderData (Invoice+)><!ATTLIST OrderData userName CDATA #IMPLIED status (PleaseCall | FYI | PleaseFulfill | Fulfilled) #IMPLIED><!ELEMENT Invoice (Customer, Part+)><!ATTLIST Invoice orderDate CDATA #REQUIRED shipDate CDATA #REQUIRED><!ELEMENT Customer EMPTY><!ATTLIST Customer name CDATA #REQUIRED…..
• add some routing information
<OrderData> userName=“Ned Flanders” status=”FYI”> <Invoice orderDate="10/17/2000" shipDate="10/20/2000"> <Customer name="Homer J. Simpson" address="742 Evergreen Terrace“…..
<!ELEMENT OrderData (Invoice+)><!ATTLIST OrderData userName CDATA #IMPLIED status (PleaseCall | FYI | PleaseFulfill | Fulfilled) #IMPLIED transactionID CDATA #IMPLIED><!ELEMENT Invoice (Customer, Part+)><!ATTLIST Invoice orderDate CDATA #REQUIRED
• request-response pairs
* request
<OrderData> userName=“Ned Flanders” status=”FYI” transactionID=“101700A1B12”> <Invoice orderDate="10/17/2000" shipDate="10/20/2000"> <Customer name="Homer J. Simpson" address="742 Evergreen Terrace“…..
<!ELEMENT OrderDataResponse EMPTY><!ATTLIST OrderDataResponse status (Accepted | Errors | TooBusy ) #REQUIRED stateDetail CDATA #IMPLIED transactionID CDATA #REQUIRED>
* Response
<OrderDataResponse statys=“Accepted” transactionID=“101700A1B12” />
<OrderDataResponse statys=“Errors” statusDetail=“Unknown customer.” transactionID=“101700A1B12” />
SOAP 웹상의 객체들을 액세스하기 위한 마이크로소프트의
프로토콜 이 프로토콜은 HTTP 를 사용하여 인터넷에 텍스트
명령어를 보내기 위해 XML 구문을 씀 SOAP 은 COM, DCOM, 인터넷 익스플로러 , 마이크로
소프트의 자바 이행등에서 지원됨 Platform-independent component
instantiation and remote procedure calls Providing meta-information about a
document in the form of an envelope. Delivering XML documents over existing
HTTP channels
SOAP Envelope HTTP 를 이용하여 XML document 를 전송하기
위해서는 SOAP envelope structure 로 document 를 encapsulate 해야 함
<SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelop/”> <SOAP-ENV:Header> </SOAP-ENV:Header> <SOAP-ENV:Body> </SOAP-ENV:Body></SOAP-ENV:Envelope>
SOAP Header
<SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelop/”> <SOAP-ENV:Header> <invoice:MessageStatus xmlns:invoice=“http://www.invoicesystem.com/soap”> <invoice:status>Resend</invoice:status> </invoic:MessageStatus> </SOAP-ENV:Header> <SOAP-ENV:Body> </SOAP-ENV:Body></SOAP-ENV:Envelope>
<SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelop/”> <SOAP-ENV:Header> <invoice:MessageStatus xmlns:invoice=“http://www.invoicesystem.com/soap”> SOAP-ENV:mustUnderstand=“1”> <invoice:status>Resend</invoice:status> </invoic:MessageStatus> </SOAP-ENV:Header> <SOAP-ENV:Body> </SOAP-ENV:Body></SOAP-ENV:Envelope>
• client 가 message 를 handle 하는데 additional processing information 을 제공
SOAP Body
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header> <invoice:MessageStatus xmlns:invoice="http://www.invoicesystem.com/soap" SOAP-ENV:mustUnderstand="1"> <invoice:status>Resend</invoice:status> </invoice:MessageStatus> </SOAP-ENV:Header> <SOAP-ENV:Body> <Invoice customerIDREF="c1" orderDate="10/17/2000" shipDate="10/20/2000"> <LineItem partIDREF="p1" quantity="17" price="0.15" /> <LineItem partIDREF="p2" quantity="13" price="0.25" /> </Invoice>
<Customer CustomerID="c1" name="Homer J. Simpson" address="742 Evergreen Terrace" city="Springfield" state="KY" postalCode="12345" /> <Part PartID="p1" name="grommets" size="3 in." color="blue" /> <Part PartID="p2" name="sprockets" size="2 in." color="red" /> <SOAP-ENV:Fault> <SOAP-ENV:faultcode>SOAP-ENV: Client.BusinessRule.NotFound </SOAP-ENV:faultcode> <SOAP-ENV:faultstring>The resent record was not found. </SOAP-ENV:faultstring> <SOAP-ENV:detail> <error:BusinessRule xmlns:error= "http://www.invoicesystem.com/soap"> <BusinessRule>ResendNotMatched</BusinessRule> <ErrorCode>1007</ErrorCode> </error:BusinessRule> </SOAP-ENV:detail> </SOAP-ENV:Fault> </SOAP-ENV:Body></SOAP-ENV:Envelope>
• contains the actual message
SOAP Fault Element Faultcode Element(1/2)
SOAP message 를 parse 할 때 일어나는 error 를 가리킴 versionMismatch : SOAP Envelop element 에 맞는
namespace 가 있는지 체크 MustUnderstand :processor 가 Messagestatus ele
ment 를 어떻게 handle 해야 할 지 모르면 sender에게 error message 를 return
SOAP Fault Element Faultcode Element(2/2)
Client : 잘못된 형태의 message 나 적당하지 않은 information 을 contain 하고 있을 경우
Server : message 의 content 에 접근할 수 없을 경우
<SOAP-ENV:Fault> <SOAP-ENV:faultcode>SOAP-ENV:Server.OutOfMemory</SOAP-ENV:faultcode></SOAP-ENV:Fault>
SOAP Fault Element Faultstring Element
Error 가 발생했을 때 human-readable description 을 제공
<SOAP-ENV:Fault> <SOAP-ENV:faultcode>SOAP-ENV:Server.OutOfMemory</SOAP-ENV:faultcode> <SOAP-ENV:faultstring>Out of memory.</SOAP-ENV:faultstrng></SOAP-ENV:Fault>
SOAP Fault Element Detail element
XML payload 과정에서 발생하는 error 를 describe
<SOAP-ENV:Fault> <SOAP-ENV:faultcode>SOAP-ENV:Client.BusinessRule.NotFound </SOAP-ENV:faulcode> <SOAP-ENV:faultstring>The resent record was not found. </SOAP-ENV:faultstring> <SOAP-ENV:detail> <error:BusinessRule xmlns:error=“http://www/invoicesystem.com/soap”> <BusinessRule>ResendNotMatched</BusinessRule> <ErrorCode>1007</ErrorCode> </error:BusinessRule> <SOAP-ENV:detail></SOAP-ENV:Fault>
Transmission Over HTTP HTTP SOAP Request
SOAPAction SOAP request 를 위해 정의된 additional head
er field
SOAPAction: “http://www.invoiceserver.com/soap/handler.exe#Invoice”SOAPAction: “ ”SOAPAction:
Transmission Over HTTP
POST / soap /Handler HTTP/1.1Content-Type: text/xml; charset=“utf-8”Content-Length: nnnnSOAPAction: “ ”
<SOAP-ENV: Envelope xmlns : SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/”> <SOAP-ENV: Header> <invoice:MessageStatus xmlns:invoice=http://www.invoicesystem.com/soap SOAP-ENV:mustUnderstand=“1”> <invoice:status>Resend</invoice:status> <invoice:MessageStatus> …..
Transmission Over HTTP HTTP SOAP Response
HTTP/1.1 200 OKContent-Type: text/xml; charset=“utf-8”Content-Length: nnnn
<SOAP-ENV:Envelope <SOAP-ENV:Body/></SOAP-ENV:Envelope>
Transmission Over HTTP If the Handler resource doesn’t know how
to handle the MessageStatus
HTTP/1.1 500 Internal Server ErrorContent-Type: text/xml; charset=“utf-8”Content-Length: nnnn
<SOAP-ENV: Envelope xmlns : SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/”> <SOAP-ENV: Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:MustUnderstand</faultcode> <faultstring>MessageStatus header not recognized</faultstring> </SOAP-ENV:Fault> </SOAP-ENV:Body></SOAP-ENV:Envelope>