Problems accessing WSDL with AJAX

南楼画角 提交于 2019-12-13 05:34:06

问题


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>

回答1:


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

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.



来源:https://stackoverflow.com/questions/15526436/problems-accessing-wsdl-with-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!