javascript AJAX通过SOAP访问的WebService

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript AJAX通过SOAP访问的WebService相关的知识,希望对你有一定的参考价值。

function callAjaxWebservice() {
    var data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
                "xmlns:ser=\"http://webService.clipathway.funso.com/\">" +
                    "<soapenv:Header/>" +
                        "<soapenv:Body>" +
                            "<ser:functionName>" +
                                "<paramName>wu</paramName>" +
                            "</ser:functionName>" +
                        "</soapenv:Body>" +
                    "</soapenv:Envelope>";

    console.log("call ajax");
    try {
        $.ajax({
            type: "POST", //访问WebService使用post方式请求
            contentType: "text/xml;utf-8", //使用的xml格式的
            url: "http://localhost:8080/xxxx/cxf/xxxx", //调用WebService的地址和方法名称组合
            data: data, //这里是要传递的参数
            dataType: "xml", //参数类型为xml
            success: function (result) {
                console.log("call succ:");
                console.log(result);
            },
            error: function (res, err) {
                console.log("call failed:" + res.responseText);
            }
        })
    } catch (ex) {
        console.log(ex);
    }
}

以上是关于javascript AJAX通过SOAP访问的WebService的主要内容,如果未能解决你的问题,请参考以下文章

对 SOAP Web 服务的 JQuery AJAX 调用 - 访问被拒绝。在 SOAP UI 中工作

使用 Javascript 与 SOAP API 对话

WebService的两种方式SOAP和REST比较

Javascript 可以访问 Ajax 文本/html 响应的 DOM 吗?

(转)WebService的两种方式soap和rest的比较

html 通过JavaScript测试SharePoint soap服务