응답 사용자 지정

  • 릴리스 버전: Xanadu
  • 업데이트 날짜 2024년 08월 01일
  • 읽기2분
  • 다음 예시에 따라 SOAP 응답의 XML 페이로드를 사용자 지정하고 제어합니다.

    시작하기 전에

    필요한 역할: web_service_admin 또는 admin

    프로시저

    1. XMLDocument 스크립트 포함 객체를 사용하여 사용자 지정된 XML 문서를 만듭니다.
      주:
      범위가 지정된 애플리케이션에서 스크립트 기반 웹 서비스를 만들 때는 XMLDocument2 API를 사용해야 합니다.
    2. 해당 문서 요소를 스크립트된 웹 서비스에서 response.soapResponseElement 변수로 설정합니다.
      예를 들어, 다음과 같이 스크립트된 웹 서비스 스크립트가 있습니다.
      var xmldoc = new XMLDocument2();
          xmldoc.parseXML("<myResponse></myResponse>");
          xmldoc.createElementWithTextValue("element_one", "test");  
          xmldoc.createElementWithTextValue("element_two", "new2 value");  
      
          var el = xmldoc.createElement("element_three");
          xmldoc.setCurrentElement(el);  
          xmldoc.createElementWithTextValue("newChild", "test child element");
      
          response.soapResponseElement = xmldoc.getDocumentElement();
      다음 요청을 수락하는 데 사용됩니다.
      <soapenv:Envelope 
         xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
         xmlns:tes="http://www.service-now.com/TestCustomResponse">
         <soapenv:Header/>
         <soapenv:Body>
            <tes:execute/>
         </soapenv:Body>
      </soapenv:Envelope>
      다음 SOAP 응답으로 응답합니다.
      <soapenv:Envelope 
          xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
          xmlns:tes="http://www.service-now.com/TestCustomResponse">
         <soapenv:Header/>
         <soapenv:Body>
            <myResponse>
               <element_one>test</element_one>
               <element_two>new2 value</element_two>
               <element_three>
                  <newChild>test child element</newChild>
               </element_three>
            </myResponse>
         </soapenv:Body>
      </soapenv:Envelope>

      WSDL 지원은 외부에서 작성해야 합니다. SOAP 엔드포인트는 해당 스크립트된 웹 서비스로 다시 참조되어야 합니다.