1

我正在尝试从 HTML 页面发布到 Service Now URL。我做不到。我会要求有人在这方面帮助我。

<html>
<body>
<button onclick="createRecord()">Create Soap</button>


<script src="jquery-1.6.4.js"></script>
<script language="javascript">
function createRecordCallback (xmlHttpRequest, status) {

  var sys_id = $(xmlHttpRequest.responseXML).find('sys_id').text();
  var tex = $(xmlHttpRequest.responseXML).text();
  if (status == "success") {
     var sys_id = $(xmlHttpRequest.responseXML).find('sys_id').text();
     alert(sys_id);
  } else {
     alert('error page'+sys_id+'is the sys id');
  }
}
function  createRecord() {
   var sel = '';
   var desc_field = 'comments';
     var instance = 'abc.service-now.com';
     var table = 'incident';
     var soapMessage = '<?xml version="1.0" encoding="UTF-8"?>';

     soapMessage += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inc="http://www.service-now.com/incident">';
     soapMessage += '<soapenv:Header/><soapenv:Body><inc:insert>';
     soapMessage += '<short_description>' + 'Incident Created' + '</short_description>';

     soapMessage += '</inc:insert></soapenv:Body></soapenv:Envelope>';


     $.ajax({
       url: "https://abc.service-now.com/incident.do?SOAP",
       type: "POST",
       dataType: "xml",
       username: "admin",
       password:"admin",
       data: soapMessage,
       complete: createRecordCallback,
       contentType: "text/xml; charset=\"utf-8\""

   });
   alert(soapMessage);
}
</script>
</body>

</html>

我发布到 SOAP 端点https://abc.service-now.com/incident.do?SOAP。我正在尝试使用该 WebService 的插入方法。

请注意,一个非常相似的代码正在同一端点的 chrome 扩展中工作。

谢谢!

4

0 回答 0