---
sourceDocument: オーストラリア API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/api-reference

 Release :

    - australia

ft:locale :

    - ja-JP

ft:publication_title :

    - オーストラリア API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# 応答をカスタマイズ

# 応答をカスタマイズ {#ariaid-title1}

* リリースバージョン: Australia
* 
* 更新日 2026年03月12日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：2分

次の例に従って、SOAP 応答の XML ペイロードをカスタマイズおよび制御します。

## 始める前に

必要なロール:web_service_admin または admin

## 手順

1. [XMLDocument](https://servicenow-prod.fluidtopics.net/Oiip1V9Jm2mzp1dWNHDsWQ "XML ドキュメント (文字列) から XML データを解析および抽出するための JavaScript オブジェクトラッパー。") スクリプトインクルードオブジェクトを使用して、カスタマイズされた XML ドキュメントを作成します。  
   注:  
   スコープ対象のアプリケーションでスクリプト付き Web サービスを作成する場合は、 [XMLDocument2](https://servicenow-prod.fluidtopics.net/L9OxoQS8whWpiRBu1c5rPw#c_XMLDocument2ScopedAPI "XMLDocument2 API は、XML 文字列から XML データを解析および抽出するための JavaScript オブジェクトラッパーです。") API を使用する必要があります。
2. スクリプト化された Web サービスで、そのドキュメント要素を変数 <var class="keyword varname">response.soapResponseElement</var> に設定します。  
   たとえば、次のスクリプト化された Web サービススクリプトです。

       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 エンドポイントは、問題のスクリプト化された Web サービスに参照する必要があります。

