WebService-面向服务编程SOA
WebService-远程通信
运行效果:
1:添加服务器引用http://www.webxml.com.cn/WebServices/WeatherWebService.asmx
添加表格
<?xml version="1.0" encoding="utf-8"?> <!-- 有关如何配置 ASP.NET 应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> </system.web> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="WebService1Soap" /> <binding name="WeatherWebServiceSoap" /> </basicHttpBinding> <customBinding> <binding name="WeatherWebServiceSoap12"> <textMessageEncoding messageVersion="Soap12" /> <httpTransport /> </binding> </customBinding> </bindings> <client> <endpoint address="http://localhost:50382/WebService1.asmx" binding="basicHttpBinding" bindingConfiguration="WebService1Soap" contract="ServiceReference1.WebService1Soap" name="WebService1Soap" /> <endpoint address="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx" binding="basicHttpBinding" bindingConfiguration="WeatherWebServiceSoap" contract="ServiceReference3.WeatherWebServiceSoap" name="WeatherWebServiceSoap" /> </client> </system.serviceModel> </configuration>
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace BBFJ.WebFormApp
{
public partial class Index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//ServiceReference1.WebService1SoapClient client = new ServiceReference1.WebService1SoapClient();
//int sum = client.Add(3,6);
//Response.Write(sum);
//Response.Write(client.LoadUserInfoList());
ServiceReference3.WeatherWebServiceSoapClient client = new ServiceReference3.WeatherWebServiceSoapClient();
DataSet ds = client.getSupportDataSet();
this.GridView1.DataSource = ds.Tables[0];
this.GridView1.DataBind();
}
}
}