阿贾克斯SOAP跨域“POST”错误的请求400错误、SOAP、阿贾克斯、跨域

2023-09-11 01:23:03 作者:在回忆里流浪

我被困在下面的SOA prequest',我尝试测试我的netbeans连接跨域访问,但不断失败,任何人都可以帮我指出我的错误?

I was stuck on below the 'soapRequest', I try to test my netbeans connect cross domain access but keep on failing, anyone can help me point out my mistake?

添加上,我安装了允许控制 - 允许 - 原产地在我的谷歌Chrome浏览器,并试图浏览器插件的海报来测试'得到'和'后'的工作。

Add on, I installed 'Allow-Control-Allow-Origin' on my google chrome browser and also tried to browser poster plugin to test the 'get' and 'post' are work.

function submitLogIn(username, passw) {
    var userId = document.getElementById(username).value;
    var userPass = document.getElementById(passw).value;

    var soap1 = '<soap:Envelope ';
    var soap2 = 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ';
    var soap3 = 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ';
    var soap4 = 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> ';
    var soap5 = '<soap:Body> ';
    var soap6 = '<Login xmlns="S2Ed"> ';
    var soap7 = '<userid>' + userId + '</userid> ';
    var soap8 = '<password>' + userPass + '</password> ';
    var soap9 = '</Login>';
    var soap10 = '</soap:Body>';
    var soap11 = '</soap:Envelope>';
    var soapMessage = soap1 + soap2 + soap3 + soap4 + soap5 + soap6 + soap7 + soap8 + soap9 + soap10 + soap11;

    // Call + ing...... 
    CallAjax(soapMessage);
}

function CallAjax(soapMessage) {
    console.log(soapMessage.toString());

    $.support.cors = true;
    $.ajax({
        type: 'POST',
        url: http://localhost:5566/Test.svc,
        // contentType: 'application/soap+xml',
        // content-Type: 'text/plain',
        contentType: 'text/xml; charset=utf-8',
        async: true, 
        dataType: 'xml',
        crossDomain: true,
        // processData: false,
        headers: {
            SOAPAction: 'S2Ed/App/Login'
        },
        data: soapMessage,
        success: function (soapResponse) {
            console.log(soapResponse);
            console.log(soapResponse.toString());
            console.log(soapResponse.toJSON());
            console.log(soapResponse.toXML());
        },
        error: function (soapResponse) {
            alert("Failed SOAP ");
        }
    });
}

下面是错误消息 在主线程同步XMLHtt prequest是因为其不利影响到最终用户的体验pcated德$ P $。如需更多帮助,请查看 http://xhr.spec.whatwg.org/ 。 (15:39:52:688 |警告,德precation)   在的public_html / JS / jQuery的-1.11.3.min.js:5

Below is the error message Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/. (15:39:52:688 | warning, deprecation) at public_html/js/jquery-1.11.3.min.js:5

无法加载资源:与400(错误请求)状态的服务器响应(:39:58:15 281 |错误,网络)   在的http://本地主机:5566 / Test.svc

Failed to load resource: the server responded with a status of 400 (Bad Request) (15:39:58:281 | error, network) at http://localhost:5566/Test.svc

XMLHtt prequest无法加载的http://本地主机:5566 / Test.svc 。无效的HTTP状态code 400(15:39:58:282 |错误,JavaScript的)   在的public_html / index.html的

XMLHttpRequest cannot load http://localhost:5566/Test.svc. Invalid HTTP status code 400 (15:39:58:282 | error, javascript) at public_html/index.html

推荐答案

错误400通常意味着你的东西提交到服务器不喜欢的服务器。即提交姓名的年龄字段,等等

Error 400 usually means you submitted something to the server which the server does not like. I.e submitting the name in the age field, etc

要添加的,它可能是可能是您的XML请求是错误的。你可以在控制台打印出来,看看它是否是一个有效的XML?

To add on, it might be possible that your request xml is wrong. Can you print it in console and see if it's a valid xml?

 
精彩推荐