1

jquery.ajax で Web サービスを呼び出そうとしています。

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 リクエストを作成するときは、jQuery が XML リクエストを文字列に変換しないように を設定processDataしてください。false

$.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 に答える