如何使用AJAX调用特定的Web服务方法? [英] How do I call a specific web service method with AJAX?

查看:117
本文介绍了如何使用AJAX调用特定的Web服务方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过ajax调用特定的WSDL方法.我有以下服务:

How do I call a specific WSDL method via ajax.. I have the following service:

http://newsite.wrapcompliance.org/FactoriesWS.wsdl

,并且我试图调用方法factCountByCountryID(),当给定3个字符串时,该方法返回一个整数.到目前为止的代码如下:

and I'm trying to call the method factCountByCountryID(), which returns an integer when given a 3 character string. Code so far is as follows:

<h3>jQuery Test</h3>

<script type="text/javascript">

function callService()
{
$.ajax
({
    url: "http://newsite.wrapcompliance.org/FactoriesWS.wsdl",
    type: "POST",
    dataType: "html",
    data: {"countryCd":"BGD"},
    success: processData,
    error: onError
});

return false;
}

function processData(xml)
{
    alert(xml);
}

function onError(request, status, error)
{
alert("It didn't work!!!");
}

</script>

<form method="post" action="">
    <input type="button" value="Do it now!!" onclick="callService(); return false"/>
    </form>

推荐答案

使用 jQuery.soap 插件,它将为您处理SOAP部分.您需要先对其进行配置,然后才能使用:

Use jQuery.soap plugin which will handle the SOAP part for you. You need to configure it first and than you can use:

$.soap({
    method: 'factCountByCountryID',
    params: {
        countryCd: 'BGD',
    },
    success: function (data) {
        // do stuff with data
    }
});

这篇关于如何使用AJAX调用特定的Web服务方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆