【问题标题】:How To Send SOAP Header With Jquery, Ajax And Get Response From The Server如何使用 Jquery、Ajax 发送 SOAP 标头并从服务器获取响应
【发布时间】:2018-08-02 04:48:09
【问题描述】:

我正在创建一个网页。在此网页中,我想显示通过 Web 服务获取的详细信息。但是,事情是在这样做之前,我必须发送标头并从服务器获取访问令牌。然后我实现了这样的代码。现在网络浏览器的控制台没有向我显示任何类型的错误。 但是,当我尝试提醒响应代码时,它显示我未定义。

我想要的是显示或提醒 Response sessionId。我该怎么做??

$(document).ready(function() {
  $.ajax({
    type: 'POST',
    url: 'AmaRes.xml',
    contentType: 'text/xml; charset=utf-8',
    headers: {
      SOAPAction: 'WSDL_File.wsdl'
    },
    data: '<?xml version="1.0"?><Security_Authenticate><userIdentifier><sourceOffice>Value1</sourceOffice></originIdentification><originatorTypeCode>Value2</originatorTypeCode><originator>Value3</originator></userIdentifier><dutyCode><dutyCodeDetails><referenceQualifier>Value4</referenceQualifier><referenceIdentifier>Value5</referenceIdentifier></dutyCodeDetails></dutyCode><systemDetails><organizationDetails><organizationId>Value6</organizationId></organizationDetails></systemDetails><passwordInfo><dataLength>8</dataLength><dataType>E</dataType><binaryData>Value7</binaryData></passwordInfo></Security_Authenticate>',
    success: function(xmlResponse) {
      var xmlhttp = new window.XMLHttpRequest();

      xmlResponse = $.parseXML(xmlResponse),
        $xml = $(xmlResponse),
        $title = $xml.find("statusCode"); //to get the ResponseId for example
      alert(($xml).find("wss:Session").attr("awss:SessionId"));
    },
  });

});

AmaRes.xml 是响应 xml 文件。

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:awss="http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd">
  <soap:Header>
    <awss:Session>
      <awss:SessionId>Value1</awss:SessionId>
      <awss:SequenceNumber>1</awss:SequenceNumber>
      <awss:SecurityToken>Value2</awss:SecurityToken>
    </awss:Session>
  </soap:Header>
  <soap:Body>
    <Security_AuthenticateReply xmlns="http://xml.amadeus.com/VLSSLR_06_1_1A">
      <processStatus>
        <statusCode>Value3</statusCode>
      </processStatus>
    </Security_AuthenticateReply>
  </soap:Body>
</soap:Envelope>

【问题讨论】:

    标签: javascript jquery ajax soap


    【解决方案1】:

    【讨论】:

    • 不走运.. :/ 还有其他方法吗??
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多