1

我正在尝试使用 jquery.ajax 调用我的网络服务。

jQuery.support.cors = true;
    $.ajax({
        type: 'POST',
        url: wsUrl,
        contentType: "text/xml; charset=utf-8",
        dataType: "xml",
        cache: false,
        crossDomain: true,
        data: soapRequest,
        success: reqSuccess,
        error: reqError
    });

我得到“拒绝访问”-错误和状态/readyState 0。

如果我使用 SoapUI 向我的 web 服务发出请求,它工作得很好。

4

1 回答 1

1

发出 SOAP 请求时,请确保设置processDatafalse以防止 jQuery 将您的 XML 请求转换为字符串。

$.ajax({
    type: 'POST',
    url: wsUrl,
    contentType: "text/xml; charset=utf-8",
    dataType: "xml",
    cache: false,
    crossDomain: true,
    data: soapRequest,
    processData: false,
    success: reqSuccess,
    error: reqError
});

来自文档:http ://api.jquery.com/jQuery.ajax/

processData (default: true)
Type: Boolean
By default, data passed in to the data option as an object (technically, anything 
other than a string) will be processed and transformed into a query string, fitting 
to the default content-type "application/x-www-form-urlencoded". If you want to send 
a DOMDocument, or other non-processed data, set this option to false.
于 2013-11-13T13:41:32.727 回答