반응형

SOAP - 오류

 

처리 중 오류가 발생하면 SOAP 메시지에 대한 응답은 메시지 body SOAP 오류 요소이며 오류는 SOAP 메시지의 보낸 사람에게 반환됩니다.

SOAP 오류 메커니즘은 미리 정의된 코드, 설명 및 오류를 생성한 SOAP 프로세서의 주소를 포함하여 오류에 대한 특정 정보를 반환합니다.

 

주의 사항

·   SOAP 메시지는 하나의 오류 블록만 전달할 수 있습니다.

·   결함은 SOAP 메시지의 선택적 부분입니다.

·   HTTP 바인딩의 경우 성공적인 응답은 200~299 범위의 상태 코드에 연결됩니다.

·   SOAP 결함은 500~599 범위의 상태 코드와 연결됩니다.

 

결함의 하위 요소

SOAP 오류에는 다음과 같은 하위 요소가 있습니다.

Sr.No 하위 요소 및 설명
1 <faultCode>
오류 클래스를 나타내는 데 사용되는 텍스트 코드입니다사전 정의된 오류 코드 목록은 다음 표를 참조하십시오.
2 <faultString>
오류를 설명하는 문자 메시지입니다.
3 <faultActor>
누가 오류를 일으켰는지 나타내는 텍스트 문자열입니다. SOAP 메시지가 SOAP 메시지 경로의 여러 노드를 통해 이동하고 클라이언트가 오류를 일으킨 노드를 알아야 하는 경우에 유용합니다최종 목적지로 작동하지 않는 노드는 
faultActor 
요소를 포함해야 합니다.
4 <detail>
응용 프로그램별 오류 메시지를 전달하는 데 사용되는 요소입니다상세 요소는 상세 항목이라는 하위 요소를 포함할 수 있습니다.

 

SOAP 오류 코드

아래에 정의된 faultCode 값은 오류를 설명하는 동안 faultcode 요소에 사용해야 합니다.

Sr.No 오류 및 설명
1 SOAP-ENV:VersionMismatch
SOAP envelope 요소에 대해 잘못된 네임스페이스를 찾았습니다.
2 SOAP-ENV:MustUnderstand
mustUnderstand 속성이 "1"로 설정된 Header 요소의 직계 자식 요소를 이해하지 못했습니다.
3 SOAP-ENV:Client
메시지 형식이 잘못되었거나 잘못된 정보가 포함되어 있습니다.
4 SOAP-ENV:Server
서버에 문제가 있어 메시지를 진행할 수 없습니다.

 

SOAP 오류 예

다음 코드는 샘플 오류입니다클라이언트가 ValidateCreditCard 라는 메서드를 요청했지만 서비스는 이러한 메서드를 지원하지 않습니다이것은 클라이언트 요청 오류를 나타내며 서버는 다음 SOAP 응답을 반환합니다.

 

<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:xsi = "http://www.w3.org/1999/XMLSchema-instance"
   xmlns:xsd = "http://www.w3.org/1999/XMLSchema">

   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode xsi:type = "xsd:string">SOAP-ENV:Client</faultcode>
         <faultstring xsi:type = "xsd:string">
            Failed to locate method (ValidateCreditCard) in class (examplesCreditCard) at
               /usr/local/ActivePerl-5.6/lib/site_perl/5.6.0/SOAP/Lite.pm line 1555.
         </faultstring>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

SOAP - 인코딩

SOAP에는 데이터 유형을 인코딩하기 위한 기본 제공 규칙 세트가 포함되어 있습니다이를 통해 SOAP 메시지는 integer, float, double 또는 array와 같은 특정 데이터 유형을 나타낼 수 있습니다.

 

·   SOAP 데이터 유형은 스칼라 유형과 복합 유형의 두 가지 광범위한 범주로 나뉩니다.

·   스칼라 유형에는 이름, 가격 또는 제품 설명과 같은 정확히 하나의 값이 포함됩니다.

·   복합 유형에는 구매 주문서 또는 주식 시세 목록과 같은 여러 값이 포함됩니다.

·   복합 유형은 배열과 구조체로 더 세분화됩니다.

·   SOAP 메시지의 인코딩 스타일은 SOAP-ENV:encodingStyle 속성을 통해 설정됩니다.

·   SOAP 1.1 인코딩을 사용하려면 http://schemas.xmlsoap.org/soap/encoding/ 값을 사용하십시오.

·   SOAP 1.2 인코딩을 사용하려면 http://www.w3.org/2001/12/soap-encoding 값을 사용하십시오.

·   최신 SOAP 사양은 XML Schema에 의해 정의된 모든 내장 유형을 채택합니다여전히 SOAP는 배열 및 참조와 같이

 

XML 스키마에 의해 표준화되지 않은 구성을 정의하기 위한 고유한 규칙을 유지합니다.

 

스칼라 유형

스칼라 유형의 경우 SOAP XML 스키마 사양에 지정된 모든 기본 제공 단순 유형을 채택합니다여기에는 string, float, double integer가 포함됩니다.

 

다음 표는 XML 스키마 파트 0 - 입문서 http://www.w3.org/TR/2000/WD-xmlschema-0-20000407/ 에서 발췌한 주요 단순 유형을 나열합니다.

XML 스키마에 내장된 단순 유형
단순형  
string Confirm this is electric.  
boolean true, false, 1, 0.  
float -INF, -1E4, -0, 0, 12.78E-2, 12, INF, NaN.  
double -INF, -1E4, -0, 0, 12.78E-2, 12, INF, NaN.  
decimal -1.23, 0, 123.4, 1000.00.  
binary 100010  
integer -126789, -1, 0, 1, 126789.  
nonPositiveInteger -126789, -1, 0.  
negativeInteger -126789, -1.  
long -1, 12678967543233  
int -1, 126789675  
short -1, 12678  
byte -1, 126  
nonNegativeInteger 0, 1, 126789  
unsignedLong 0, 12678967543233  
unsignedInt 0, 1267896754  
unsignedShort 0, 12678  
unsignedByte 0, 126  
positiveInteger 1, 126789.  
date 1999-05-31, ---05.  
time 13:20:00.000, 13:20:00.000-05:00  

 

예를 들어, 다음은 이중 데이터 유형의 SOAP 응답입니다.

<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope 
   xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope"
   xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" 
   xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
   
   <SOAP-ENV:Body>
      <ns1:getPriceResponse 
         xmlns:ns1 = "urn:examples:priceservice"  
         SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">
         <return xsi:type = "xsd:double">54.99</return>
      </ns1:getPriceResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

복합 유형

SOAP 배열에는 요소 유형과 배열 크기를 모두 지정해야 하는 매우 구체적인 규칙 집합이 있습니다. SOAP는 다차원 배열도 지원하지만 모든 SOAP 구현이 다차원 기능을 지원하는 것은 아닙니다.

배열을 생성하려면 배열의 xsi:type 으로 지정해야 합니다 . 배열에는 arrayType 속성도 포함되어야 합니다이 속성은 포함된 요소의 데이터 유형과 배열의 차원을 지정하는 데 필요합니다.

 

예를 들어 다음 속성은 10개의 이중 값 배열을 지정합니다.

arrayType = "xsd:double[10]"

대조적으로 다음 속성은 문자열의 2차원 배열을 지정합니다.

arrayType = "xsd:string[5,5]"

다음은 이중 값 배열이 있는 샘플 SOAP 응답입니다.

<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope" 
   xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" 
   xmlns:xsd = "http://www.w3.org/2001/XMLSchema">

   <SOAP-ENV:Body>
      <ns1:getPriceListResponse 
         xmlns:ns1 = "urn:examples:pricelistservice"  
         SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">

         <return xmlns:ns2 = "http://www.w3.org/2001/09/soap-encoding"  
            xsi:type = "ns2:Array" ns2:arrayType = "xsd:double[2]">
            <item xsi:type = "xsd:double">54.99</item>
            <item xsi:type = "xsd:double">19.99</item>
         </return>
      </ns1:getPriceListResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

구조체에는 여러 값이 포함되지만 각 요소는 고유한 접근자 요소로 지정됩니다예를 들어, 제품 카탈로그 내의 항목을 고려하십시오이 경우 구조체에는 제품 SKU, 제품 이름, 설명 및 가격이 포함될 수 있습니다다음은 그러한 구조체가 SOAP 메시지에서 표현되는 방법입니다.

<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope 
   xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope"
   xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" 
   xmlns:xsd = "http://www.w3.org/2001/XMLSchema">

   <SOAP-ENV:Body>
      <ns1:getProductResponse
         xmlns:ns1 = "urn:examples:productservice" 
         SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">

         <return xmlns:ns2 = "urn:examples" xsi:type = "ns2:product">
            <name xsi:type = "xsd:string">Red Hat Linux</name>
            <price xsi:type = "xsd:double">54.99</price>
            <description xsi:type = "xsd:string">
               Red Hat Linux Operating System
            </description>
            <SKU xsi:type = "xsd:string">A358185</SKU>
         </return>
      </ns1:getProductResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

참고 - SOAP 코드를 작성하는 동안 적절한 들여쓰기에 주의하십시오구조체의 각 요소는 고유한 접근자 이름으로 지정됩니다예를 들어 위의 메시지에는 이름, 가격, 설명 및 SKU의 네 가지 접근 요소가 포함됩니다각 요소는 고유한 데이터 유형을 가질 수 있습니다예를 들어 name은 문자열로 지정되고 price double로 지정됩니다.

 

SOAP - 전송

SOAP는 전송 프로토콜에 연결되어 있지 않습니다. SOAP SMTP, FTP, IBM MQSeries 또는 MSMQ(Microsoft Message Queuing)를 통해 전송할 수 있습니다.

SOAP 사양에는 HTTP에 대한 세부 정보만 포함됩니다. HTTP는 가장 널리 사용되는 SOAP 전송 프로토콜로 남아 있습니다.

 

HTTP를 통한 SOAP

논리적으로 SOAP 요청은 HTTP 요청을 통해 전송되고 SOAP 응답은 HTTP 응답의 내용 내에서 반환됩니다. SOAP 요청은 HTTP GET을 통해 보낼 수 있지만 사양에는 HTTP POST에 대한 세부 정보만 포함되어 있습니다.

또한 콘텐츠 유형을 text/xml로 설정하려면 HTTP 요청과 응답이 모두 필요합니다.

SOAP 사양은 클라이언트가 SOAPAction 헤더를 제공해야 한다고 요구 하지만 SOAPAction 헤더의 실제 값은 SOAP 서버 구현에 따라 다릅니다.

 

예를 들어, XMethods에서 호스팅하는 AltaVista BabelFish 번역 서비스에 액세스하려면 다음을 SOAPAction 헤더로 지정해야 합니다.

urn:xmethodsBabelFish#BabelFish

서버에 전체 SOAPAction 헤더가 필요하지 않더라도 클라이언트는 빈 문자열("") 또는 null 값을 지정해야 합니다예를 들어 -

SOAPAction: ""
SOAPAction:

 

다음은 HTTP를 통해 XMethods Babelfish 번역 서비스로 전송된 샘플 요청입니다.

POST /perl/soaplite.cgi HTTP/1.0
Host: services.xmethods.com
Content-Type: text/xml; charset = utf-8
Content-Length: 538
SOAPAction: "urn:xmethodsBabelFish#BabelFish"

<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope 
   xmlns:SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/" 
   xmlns:xsi = "http://www.w3.org/1999/XMLSchema-instance"
   xmlns:xsd = "http://www.w3.org/1999/XMLSchema">

   <SOAP-ENV:Body>
      <ns1:BabelFish
         xmlns:ns1 = "urn:xmethodsBabelFish"
         SOAP-ENV:encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/">
         <translationmode xsi:type = "xsd:string">en_fr</translationmode>
         <sourcedata xsi:type = "xsd:string">Hello, world!</sourcedata>
      </ns1:BabelFish>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

컨텐츠 유형 및 SOAPAction 헤더를 확인하십시오또한 BabelFish 메서드에는 두 개의 String 매개변수가 필요합니다번역 모드 en_fr은 영어에서 프랑스어로 번역합니다.

 

다음은 XMethods의 응답입니다.

HTTP/1.1 200 OK
Date: Sat, 09 Jun 2001 15:01:55 GMT
Server: Apache/1.3.14 (Unix) tomcat/1.0 PHP/4.0.1pl2
SOAPServer: SOAP::Lite/Perl/0.50
Cache-Control: s-maxage = 60, proxy-revalidate
Content-Length: 539
Content-Type: text/xml

<?xml version = "1.0" encoding = "UTF-8"?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENC = "http://schemas.xmlsoap.org/soap/encoding/"
   SOAP-ENV:encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
   xmlns:xsi = "http://www.w3.org/1999/XMLSchema-instance"
   xmlns:SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:xsd = "http://www.w3.org/1999/XMLSchema">
   
   <SOAP-ENV:Body>
      <namesp1:BabelFishResponse xmlns:namesp1 = "urn:xmethodsBabelFish">
         <return xsi:type = "xsd:string">Bonjour, monde!</return>
      </namesp1:BabelFishResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

HTTP를 통해 전달되는 SOAP 응답은 동일한 HTTP 상태 코드를 따라야 합니다예를 들어 상태 코드 200 OK는 성공적인 응답을 나타냅니다상태 코드 500 내부 서버 오류는 서버 오류가 있고 SOAP 응답에 Fault 요소가 포함되어 있음을 나타냅니다.

 

SOAP -

아래 예에서 GetQuotation 요청은 HTTP를 통해 SOAP 서버로 전송됩니다요청에 QuotationName 매개변수가 있으며 응답으로 견적이 반환됩니다.

함수의 네임스페이스는 http://www.xyz.org/quotation 주소에 정의되어 있습니다.

다음은 SOAP 요청입니다.

 

POST /Quotation HTTP/1.0
Host: www.xyz.org
Content-Type: text/xml; charset = utf-8
Content-Length: nnn

<?xml version = "1.0"?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope"
   SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">

   <SOAP-ENV:Body xmlns:m = "http://www.xyz.org/quotations">
      <m:GetQuotation>
         <m:QuotationsName>MiscroSoft</m:QuotationsName>
      </m:GetQuotation>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

해당 SOAP 응답은 다음과 같습니다.

HTTP/1.0 200 OK
Content-Type: text/xml; charset = utf-8
Content-Length: nnn

<?xml version = "1.0"?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope"
   SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">

   <SOAP-ENV:Body xmlns:m = "http://www.xyz.org/quotation">
      <m:GetQuotationResponse>
         <m:Quotation>Here is the quotation</m:Quotation>
      </m:GetQuotationResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

SOAP - 표준

SOAP 1.1은 원래 2000 5월에 W3C에 제출되었습니다. 공식 제출자에는 Microsoft, IBM, Ariba와 같은 대기업과 UserLand Software DevelopMento와 같은 소규모 회사가 포함되었습니다.

2001 7 XML 프로토콜 작업 그룹은 SOAP 1.2 "작업 초안"을 발표했습니다. W3C 내에서 이 문서는 공식적으로 진행 중인 작업입니다. , 문서가 완성되기 전에 여러 번 업데이트될 가능성이 있습니다.

SOAP 버전 1.1 http://www.w3.org/TR/SOAP/ 에서 온라인으로 사용할 있습니다.

SOAP 버전 1.2의 작업 초안은 http://www.w3.org/TR/soap12/ 에서 있습니다.

W3C는 또한 핵심 SOAP 사양에서 분리되는 "첨부 파일이 있는 SOAP 메시지"에 대한 제출을 호스팅합니다이 사양을 사용하면 SOAP 메시지에 이미지 및 사운드 파일과 같은 이진 첨부 파일이 포함될 수 있습니다자세한 내용은 http://www.w3.org/TR/SOAP-attachments 에서 W3C 참고 사항을 참조하십시오.

 

반응형

'Onvif' 카테고리의 다른 글

XML 네임스페이스  (0) 2022.10.20
SOAP 메시지 구조 -1  (0) 2022.10.18
SOAP(Simple Object Access Protocal)  (1) 2022.10.05

+ Recent posts