如何调用Web服务并使用URL传递参数 [英] How can I call a web service and pass parameters using the URL
本文介绍了如何调用Web服务并使用URL传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何调用ASP .NET Web服务并使用URL传递参数?
How can I call a ASP .NET web service and pass parameters using the URL?
例如,该服务的网址是
http://[localhost]:31856/MySystem/MyAPI.asmx?op = getHeight
我尝试传递两个参数a和b
I need to pass two parameters a and b, I tried
http://[localhost]:31856/MySystem/MyAPI.asmx?op = getHeight?a = 254& b = 1
但是失败了.
请咨询.
非常感谢,
推荐答案
如果您需要传递多个参数,请使用 param1 = value1& param2 = value2
这样的格式.链接应为:
If you need to pass more than one parameter, use this format param1=value1¶m2=value2
and so on.So your link should be:
http://[localhost]:31856/MySystem/MyAPI.asmx/AnyMethodName?op=getHeight&a=254&b=1
您需要一个类似这样的方法.该方法返回一个字符串列表,仅用于演示.
You need a method like this.This method returns a list of strings,its just for demonstration.
[WebMethod]
public List<string> AnyMethodName(string op, string a, string b)
{
//Do whatever you want, get answer
return (ans.ToList());
}
这篇关于如何调用Web服务并使用URL传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文