从客户端脚本调用Web服务 [英] Web service calling from the client script

查看:68
本文介绍了从客户端脚本调用Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有一个Web服务,其返回类型为Dataset.我想通过客户端脚本调用此Web方法,并希望显示HTML表中的内容.

Hello,

I have a webservice which has a return type as Dataset. I want to call this web method form client script and wants to dispaly the content in the HTML table.

How it can be done.

推荐答案

您需要执行以下两个步骤:首先,客户端脚本必须对服务器脚本进行AJAX调用,其次,该服务器脚本需要与Web服务进行对话,并将服务返回的结果转换为HTML(或客户端脚本可以理解的其他内容).
You need to do this as two steps: first, the client script must make an AJAX call to a server script, and second, that server script needs to talk to the web service and translate the result from whatever the service returns into HTML (or something else that the client script can understand).


基于SOAP的Web服务可以是仅从服务器端调用(C#).但是,您可以使用 AJAX 从Client-Script(JavaScript)调用服务器端代码.

您可以为此使用 JQuery-Ajax .看看下面的链接.
简化Asp.Net Core Ajax
SOAP based Web Service can be called only from server-side(C#). However you can call your server-side code from your Client-Script(JavaScript) using AJAX.

You may use JQuery-Ajax for this. Have a look below link.
Simplifying Asp.Net Core Ajax


首先添加您创建的服务作为服务参考.并创建它的一个实例.

First add the service you created as service reference. And create an instance of it.

MyWebServiceSoapClient ws = new MyWebServiceSoapClient();
DataSet ds = new DataSet();
ds = ws.ResultTable();



然后将ds用作表的数据集

如果这解决了您的问题,请将其标记为答案

最好的问候,
爱德华



then use ds as your dataset for your table

if this solved your problem, mark it as answer

Best regards,
Eduard


这篇关于从客户端脚本调用Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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