zoukankan      html  css  js  c++  java
  • wcf asp.net

    WCF服务
    App_Code/Customer.cs

    C# code
    using System.Runtime.Serialization; using System.ServiceModel; //实体类 [DataContract] public class Customer { [DataMember] public string FirstName; [DataMember] public string LastName; }


    IWCF_WithDataContract.cs

    C# code
    using System.Runtime.Serialization; using System.ServiceModel; [ServiceContract] public interface IWCF_WithDataContract { [OperationContract] string HelloFirstName(Customer cust); [OperationContract] string HelloFullName(Customer cust); }
    C# code
    using System.Runtime.Serialization; using System.ServiceModel; public class WCF_WithDataContract : IWCF_WithDataContract { public string HelloFirstName(Customer cust) { return "Hello" + cust.FirstName; } public string HelloFullName(Customer cust) { return "Hello" + cust.FirstName + " " + cust.LastName; } }


    客户端asp.net代码

    C# code
    using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class WithDataContractServiceTest : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnWithData_Click(object sender, EventArgs e) { WithDataContractService.WCF_WithDataContractClient ws = new WithDataContractService.WCF_WithDataContractClient(); WithDataContractService.Customer c = new WithDataContractService.Customer(); c.FirstName = "zhong"; c.LastName = "wei"; ws.HelloFullName(c); ws.Close(); } }


    引用的实体要加DataContract标签和DataMember标签

  • 相关阅读:
    JDK有关环境变量的配置
    installation Manager的那回事
    WMB ESQL报文函数截取新的XML方法
    mb常用操作指令
    DB2报错SQLSTATE=57017 code page "1392"
    DB2操作命令
    MQ7.1及高版本的新特性
    Java项目打jar包及外部运行
    loadrunner
    Ireport5那些事
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/1929267.html
Copyright © 2011-2022 走看看