我有一个网络参考,我试图从我的Java脚本代码中调用,但是我似乎无法获得操作结果或错误.可以使用Java脚本从Web引用调用Web服务.
I have a web reference I am trying to invoke from my java script code but I can''t seem to get a result or an error for the operation. Is is possible to invoke a web service from a web reference using java script.
<ScriptManager ID="RSM1" runat="server"> <services> <asp:ServiceReference Path="myhost/services/postings/pservice.asmx" /> </services> </ScriptManager>上面是我在页面上注册Web服务的方式,下面是我的调用方法.和完整的方法.它永远不会进入完整方法或失败方法
above is how I am registering my web service with the page and below is my calling method. and complete method. It never gets to the complete or the fail method
function LoadPage() { alert("test we here in LoadPage "); PService._LoadPostingArchive(OnWSRequestCompleted, OnWSRequestFailed) } function OnWSRequestFailed(error) { alert("Stack Trace: " + error.get_stackTrace() + "\r\n" + "Error: " + error.get_message() + "\r\n" + "Status Code: " + error.get_statusCode() + "\r\n" + "Exception Type: " + error.get_exceptionType() + "\r\n" + "Timed Out: " + error.get_timedOut()); } function OnWSRequestCompleted(result) { alert("test we here "); var tableView = $find("<%= gvArchive.ClientID %>").get_masterTableView(); if (results != null) { alert("teste we in "); tableView.dataBind(); tableView.set_dataSource(result); $find("<%= RadAjaxLoadingPanel1.ClientID %>").hide("<%= gvArchive.ClientID %>"); } else { alert("test we out "); } }推荐答案
find(<%= gvArchive.ClientID%>").get_masterTableView(); if(结果!= null){ alert(测试我们在"); tableView.dataBind(); tableView.set_dataSource(result); find("<%= gvArchive.ClientID %>").get_masterTableView(); if (results != null) { alert("teste we in "); tableView.dataBind(); tableView.set_dataSource(result);
find(<%= RadAjaxLoadingPanel1.ClientID%>").hide(<%= gvArchive.ClientID%>"); } 别的 { alert(测试我们"); } } find("<%= RadAjaxLoadingPanel1.ClientID %>").hide("<%= gvArchive.ClientID %>"); } else { alert("test we out "); } }
该服务在您的应用程序本地还是在远程服务器上运行?远程服务器会给您带来麻烦,但是本地Web服务应该可以.首先,您应该使用服务器端路径,该路径应类似于以下内容: Is the service local to your application or is it running on a remote server? The remote server will give you trouble, but a local web service should be fine. First of all, you should use a server-side path, which would look something like this: <asp:ServiceReference Path="~/services/postings/pservice.asmx" />
另外,通常将通过在Web服务名称之前包含名称空间来调用服务,例如:
Also, you will typically call your service by including the namespace before the web service name, such as this:
// Namespace.WebServiceName.WebMethodName() SomeNamespace.PService._LoadPostingArchive(OnWSRequestCompleted, OnWSRequestFailed);我还注意到您在行尾没有分号.而且,如果您的网络方法具有任何参数,那么将会明显改变调用.
I also noticed you didn''t have a semicolon at the end of your line. And if your web method has any parameters, that will change the call a bit (obviously).
更多推荐
您可以从Web参考中调用Java服务来调用Web服务吗?
发布评论