同步调用webservice [英] Synchronous call to webservice

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

问题描述





我在C#中工作很多但在ajax / webservice中有点新功能。



我知道使用异步属性从同步/异步方式调用asmx webservice,例如...

例如。



Hi,

I have worked much in C# but bit new in ajax/webservice.

I know to call asmx webservice from script in sync/async manner using async attribute like...
eg.

$.ajax({ 
     type: "POST",
     url: "/Webservice/webservice1.asmx/SomeMethod",
     async: false,
     success: successMethod
});



但现在我使用ajax脚本管理器和单独的脚本文件调用相同的

例如。




but now I am calling the same using ajax script manager and from separate script file
eg.

function CallService(){
   var webServiceProxy = new testNamespace.Webservice.webservice1();
   //Code runs before calling webservice
   webServiceProxy.SomeMethod(successMethod);
   //codeLocation2
}

function successMethod(result) {
}



现在,当我调用CallService函数时,代码@ codeLocation2运行无需等待来自Web服务的响应。那么可以在运行codeLocation2之前等待结果或successmethod执行,或者只需要将其写入successMethod。



在这种情况下如何从main函数传递数据成功方法。

先谢谢。


Now when I call the CallService Function the code @ codeLocation2 runs without waiting to the response from the webservice. So is that possible to wait for the result or successmethod execution before running codeLocation2 or need to write that into successMethod only.

In such case how to pass data from main function to success method.
Thanks in Advance.

推荐答案

.ajax({
type: POST
url: / Webservice / webservice1.asmx / SomeMethod
async: false
成功:successMethod
});
.ajax({ type: "POST", url: "/Webservice/webservice1.asmx/SomeMethod", async: false, success: successMethod });



但现在我使用ajax脚本管理器和单独的脚本文件调用相同的

例如。




but now I am calling the same using ajax script manager and from separate script file
eg.

function CallService(){
   var webServiceProxy = new testNamespace.Webservice.webservice1();
   //Code runs before calling webservice
   webServiceProxy.SomeMethod(successMethod);
   //codeLocation2
}

function successMethod(result) {
}



现在,当我调用CallService函数时,代码@ codeLocation2运行无需等待来自Web服务的响应。那么可以在运行codeLocation2之前等待结果或successmethod执行,或者只需要将其写入successMethod。



在这种情况下如何从main函数传递数据成功方法。

先谢谢。


Now when I call the CallService Function the code @ codeLocation2 runs without waiting to the response from the webservice. So is that possible to wait for the result or successmethod execution before running codeLocation2 or need to write that into successMethod only.

In such case how to pass data from main function to success method.
Thanks in Advance.


这篇关于同步调用webservice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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