Sharepoint 2007 (SOAP) 中的 jQuery Ajax 请求

发布于 2024-12-07 04:01:27 字数 3010 浏览 0 评论 0原文

我有以下网络服务:

SOAP 1.1

The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.

POST /_vti_bin/QuickLinks.asmx HTTP/1.1
Host: myintracomm-design.ec.europa.eu
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://ec.europa.eu/GetSuggestions"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetSuggestions xmlns="http://ec.europa.eu/">
      <prefixText>string</prefixText>
      <count>int</count>
    </GetSuggestions>
  </soap:Body>
</soap:Envelope>

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetSuggestionsResponse xmlns="http://ec.europa.eu/">
      <GetSuggestionsResult>
        <string>string</string>
        <string>string</string>
      </GetSuggestionsResult>
    </GetSuggestionsResponse>
  </soap:Body>
</soap:Envelope>

我通过导航到以下网址找到该服务:

http ://www.bla.eu/_vti_bin/QuickLinks.asmx?op=GetSuggestions

我尝试使用以下代码发出 Ajax 请求来获取其背后的内容:

var productServiceUrl = 'http://myintracomm-design.ec.europa.eu/_vti_bin/QuickLinks.asmx?op=GetSuggestions';

function LoadData() {
    var soapEnv = 
    '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> \
           <soap:Body> \
              <GetSuggestions xmlns="http://ec.europa.eu/"> \
              <prefixText>sys</prefixTest> \
              <count>10</count> \
              </GetSuggestions> \
             </soap:Body> \
        </soap:Envelope>';

    $jQuery.ajax({
        url: productServiceUrl,
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        complete: OnLinksFetched,
        contentType: "text/xml; charset=\"utf-8\""
    });
}

function OnLinksFetched(xmlHttpRequest, status)
    {
     $jQuery(xmlHttpRequest.responseXML)
        .find('GetSuggestionsResult')
        .each(function() {
       var name = $jQuery(this).find('Name').text();
       $jQuery("#links").append(name);
     });}

我向链接添加了一个简单的 onclick 事件(仅用于测试目的)。不幸的是,我收到了错误的请求错误。这里是操作中的错误 我尝试了 SOAP 请求的许多组合(因为我没有 SOAP 经验),但没有成功。经过5天的努力,决定在这里发帖。预先感谢您的任何帮助。

I have the following web service:

SOAP 1.1

The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.

POST /_vti_bin/QuickLinks.asmx HTTP/1.1
Host: myintracomm-design.ec.europa.eu
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://ec.europa.eu/GetSuggestions"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetSuggestions xmlns="http://ec.europa.eu/">
      <prefixText>string</prefixText>
      <count>int</count>
    </GetSuggestions>
  </soap:Body>
</soap:Envelope>

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetSuggestionsResponse xmlns="http://ec.europa.eu/">
      <GetSuggestionsResult>
        <string>string</string>
        <string>string</string>
      </GetSuggestionsResult>
    </GetSuggestionsResponse>
  </soap:Body>
</soap:Envelope>

Which I locate by navigating to a url like:

http://www.bla.eu/_vti_bin/QuickLinks.asmx?op=GetSuggestions

I tried to make an Ajax request to fetch the content lying behind this, by using this code:

var productServiceUrl = 'http://myintracomm-design.ec.europa.eu/_vti_bin/QuickLinks.asmx?op=GetSuggestions';

function LoadData() {
    var soapEnv = 
    '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> \
           <soap:Body> \
              <GetSuggestions xmlns="http://ec.europa.eu/"> \
              <prefixText>sys</prefixTest> \
              <count>10</count> \
              </GetSuggestions> \
             </soap:Body> \
        </soap:Envelope>';

    $jQuery.ajax({
        url: productServiceUrl,
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        complete: OnLinksFetched,
        contentType: "text/xml; charset=\"utf-8\""
    });
}

function OnLinksFetched(xmlHttpRequest, status)
    {
     $jQuery(xmlHttpRequest.responseXML)
        .find('GetSuggestionsResult')
        .each(function() {
       var name = $jQuery(this).find('Name').text();
       $jQuery("#links").append(name);
     });}

and I added an simple onclick event to a link (just for testing purposes). Unfortunately, I get a bad request error.here is the error in action
I tried many combinations of the soap request (as I have no experience in SOAP) but with no success. Decided to post here after 5 days of effort. Thanks in advance for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅气称霸 2024-12-14 04:01:27

您可以尝试将请求标头添加到您的网络服务调用中。

$.ajax({
    url: productServiceUrl,
    beforeSend: function(xhr) {
        xhr.setRequestHeader("SOAPAction",
        "http://ec.europa.eu/GetSuggestions"
    },
    type: "POST",
    dataType: "xml",
    data: soapEnv,
    complete: OnLinksFetched,
    contentType: "text/xml; charset=\"utf-8\""
});

You could try adding a request header to your web service call.

$.ajax({
    url: productServiceUrl,
    beforeSend: function(xhr) {
        xhr.setRequestHeader("SOAPAction",
        "http://ec.europa.eu/GetSuggestions"
    },
    type: "POST",
    dataType: "xml",
    data: soapEnv,
    complete: OnLinksFetched,
    contentType: "text/xml; charset=\"utf-8\""
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文