記録なし SOAPMessageV2 の例

  • リリースバージョン: Australia
  • 更新日 2026年03月12日
  • 所要時間:1分
  • パラメーターなしで SOAPMessageV2() コンストラクターを使用して、スクリプト内で SOAP メッセージ全体を定義できます。

    このコンストラクターを使用する場合は、エンドポイントと SOAP アクションを指定する必要があります。この例では、スクリプトは空の SOAP メッセージを作成し、インシデントレコードの挿入に必要な値を設定します。

    var s = new sn_ws.SOAPMessageV2(); //create an empty SOAP message
    s.setBasicAuth('admin','admin');
    s.setSOAPAction('http://www.service-now.com/incident/insert'); //set the SOAP action to perform
    s.setEndpoint('http://<instance>.service-now.com/incident.do?SOAP'); //set the web service provider endpoint
    s.setRequestBody('<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:inc=\"http://www.service-now.com/incident\"><soapenv:Header/><soapenv:Body><inc:insert><short_description>Test Dynamic SOAP</short_description></inc:insert></soapenv:Body></soapenv:Envelope>');
    var response = s.execute();
    var xmldoc = new XMLDocument(response.getBody());
    var incident_sysid = xmldoc.getNodeText('//sys_id');