标签:UI txt 注意 接口 方法 string 技术分享 xca submit
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace DemoServiceWCF
{
// 注意: 使用“重构”菜单上的“重命名”命令,能够同一时候更改代码和配置文件里的接口名“IUser”。
[ServiceContract]
public interface IUser
{
[OperationContract]
string ShowName(string name);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace DemoServiceWCF
{
// 注意: 使用“重构”菜单上的“重命名”命令,能够同一时候更改代码、svc 和配置文件里的类名“User”。
// 注意: 为了启动 WCF 測试client以測试此服务,请在解决方式资源管理器中选择 User .svc 或 User .svc.cs,然后開始调试。
public class User : IUser
{
public string ShowName(string name)
{
string wcfName = string.Format("WCF服务,显示姓名:{0}", name);
return wcfName;
}
}
}
我们把我们刚刚建立的WCF程序“部署”在Bserver上(本教程的
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="User.aspx.cs" Inherits="DemoClientWCF.User" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtName" runat="server"></asp:TextBox><br />
<asp:Button ID="btnSubmit" runat="server" Text="測试WCF服务" OnClick="btnClick" />
</form>
</body>
</html>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DemoClientWCF.ServiceReference;
namespace DemoClientWCF
{
public partial class User : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnClick(object sender, EventArgs e)
{
UserClient user = new UserClient();
string result = user.ShowName(this.txtName.Text);
Response.Write(result);
}
}
}标签:UI txt 注意 接口 方法 string 技术分享 xca submit
原文地址:http://www.cnblogs.com/llguanli/p/6782774.html