1 新建
Silverlight应用程序项目
2在web项目中添加WCF服务
3编写WCF服务的函数方法
4 访问svc文件测试服务是否正常
5在Silverlight项目中添加服务引用
6在silverlight中调用WCF
void client_addCompleted(object sender, addCompletedEventArgs e)
{
if (e.Error == null)
{
t3.Text = e.Result.ToString();
}
2在web项目中添加WCF服务
3编写WCF服务的函数方法
4 访问svc文件测试服务是否正常
5在Silverlight项目中添加服务引用
6在silverlight中调用WCF
void client_addCompleted(object sender, addCompletedEventArgs e)
{
if (e.Error == null)
{
t3.Text = e.Result.ToString();
}
}
private void button1_Click(object sender, RoutedEventArgs e)
{
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress endPoint = new EndpointAddress("http://localhost:2798/Service1.svc");
Service1Client client = new Service1Client(binding, endPoint);
client.addCompleted += new EventHandler<addCompletedEventArgs>(client_addCompleted);
client.addAsync(Convert.ToInt32(t1.Text), Convert.ToInt32(t2.Text));
}
{
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress endPoint = new EndpointAddress("http://localhost:2798/Service1.svc");
Service1Client client = new Service1Client(binding, endPoint);
client.addCompleted += new EventHandler<addCompletedEventArgs>(client_addCompleted);
client.addAsync(Convert.ToInt32(t1.Text), Convert.ToInt32(t2.Text));
}
本文将指导您如何在Silverlight项目中集成并使用WCF服务,包括创建项目、添加服务引用、调用服务方法等关键步骤。

2561

被折叠的 条评论
为什么被折叠?



