使用AJAX访问WSDL的问题 [英] Problems accessing WSDL with AJAX

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

问题描述

我刚刚接触AJAX,并尝试通过以下代码访问我们的WSDL数据库。当我运行它,Firefox调试器说[10:27:42.805] ReferenceError:$未定义@ http://newsite.wrapcompliance.org/ajaxtest.html:14 :想法?

I'm new to AJAX and am trying to access our WSDL database through the following code. When I run it, the Firefox debugger says "[10:27:42.805] ReferenceError: $ is not defined @ http://newsite.wrapcompliance.org/ajaxtest.html:14": Thoughts?

<h3>jQuery Test</h3>

<script type="text/javascript">

function callService()
{
    $.ajax
    ({
        url: "http://newsite.wrapcompliance.org/FactoriesWS.wsdl",
        type: "POST",
        dataType: "xml",
        data: {"countryCd":"BGD"},
        contentType: "text/xml; charset=\"utf-8\"",
        success: onSuccess,
        error: onError
    });

    return false;
}

function onSuccess(data, status)
{
    alert("It worked!!");
}

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>


</body>
</html>


推荐答案

您的错误是由于实际上没有jQuery 。我看着你的示例网站和jquery在firebug的net标签中抛出一个404,意味着它没有找到。确保它指向正确的本地目录。目前正在查找 http://newsite.wrapcompliance.org/jquery-1.9。 1.min.js

Your error is the result of not actually having jQuery present. I looked at your sample site and jquery threw a 404 in the net tab of firebug, meaning it wasn't found. Make sure it's pointing to the correct local directory. Currently it is looking in http://newsite.wrapcompliance.org/jquery-1.9.1.min.js

也就是说,调用wsdl本身很可能返回wsdl的xml摘要页面,而不是一个暴露的服务。我建议在安静的服务中包装你暴露的wsdl端点。我已经做了这个多次与WebAPI RESTful服务,它总是采取了一个巨大的块出来的头痛。

That said, calling the wsdl itself will most likely return the xml summary page of the wsdl, not an exposed service. I'd recommend wrapping your exposed wsdl endpoints in restful services. I've done this multiple times with WebAPI RESTful services and it's always taken a huge chunk out of the headache.

这篇关于使用AJAX访问WSDL的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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