レコードレス SOAPMessageV2 の例

  • リリースバージョン: Washingtondc
  • 更新日 2024年02月01日
  • 読む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');