2024年6月12日发(作者:)
一、WebService在cs后台程序中的调用
A、通过命名空间和类名直接调用
示例:
WebServicews = new WebService();
string s = orld();
B、通过添加WEB引用的方式调用,首先添加WEB引用,通过URL指向WEBSERVICE,
指定WEB引用名,假设为KK;
示例:
vice n = new vice();
string ss=orld();
二、WebService在前台页面的JS 调用方法
1、首先通过下面的方法把Webservice在前台引用进来
2、然后就可以通过JS程序进行调用,示例如下:
----自写小例子---
web Service---:
[WebMethod]
public string HelloWorld() {
return "Hello World,wwg";
}
[WebMethod]
public intAddWwg(inta,int b)
{
return a + b;
}
exe---
using ost; //因为自己没有定义命名空间
namespaceCallWebService
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Service serviceWwg = new Service();
int i1 = (ng());
int i2 = (ng());
intiResult = (i1, i2);
= ng();
}
private void button2_Click(object sender, EventArgs e)
{
eserviceWwg = new
e();
string strResult = orld();
= ng();
}
}
}


发布评论