응답 사용자 지정
다음 예시를 수행하여 SOAP 응답의 XML 페이로드를 사용자 지정하고 제어합니다.
시작하기 전에
필요한 역할: web_service_admin 또는 admin
프로시저
-
XMLDocument 스크립트 포함 객체를 사용하여 사용자 지정된 XML 문서를 작성합니다.
주:범위가 지정된 애플리케이션에서 스크립트 기반 웹 서비스를 만들 때 XMLDocument2 API를 사용해야 합니다.
-
문서 요소를 스크립트된 웹 서비스에서 변수 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 엔드포인트는 해당 스크립트된 웹 서비스로 다시 참조되어야 합니다.