1

i´m trying to call my webservice with 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
    });

I get "Access denied"-Error and status / readyState 0.

If i make a request to my webservice with SoapUI, it works very well.

1 Answer 1

1

When making a SOAP request, make sure to set processData to false to prevent jQuery from converting your XML request to a string.

$.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
});

From the docs: 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.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.