zoukankan      html  css  js  c++  java
  • WCF Service 转换为Web Service 中字段属性

    1.新建WCF服务,服务中包含对象

    2.部署WCF服务,并将其转换为应用程序

    3.通过添加服务引用,使用WCF服务

    4.调用对应的对象时需要对应的值设置为True。

    参考:https://cloud.tencent.com/developer/ask/73513

    对象结构:

        public class QueryClass
        {
            public DateTime STime;//开始时间
            public DateTime ETime;//结束时间
            public string SiteCode;//工厂
            public string Department;//部门
            public string AreaNo;//区域
            public string PrdLine;//线号
            public string Type;//点检类型
            public string Shift;//班次
            public string EquipmentNo;//设备编号
            public string DailyCheckTaskID;//点检任务编号
        }

    添加引用后的代理代码

      /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.1055.0")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.datacontract.org/2004/07/EASAPPSrv")]
        public partial class QueryClass {
           
            private string areaNoField;
           
            private string dailyCheckTaskIDField;
           
            private string departmentField;
           
            private System.DateTime eTimeField;
           
            private bool eTimeFieldSpecified;
           
            private string equipmentNoField;
           
            private string prdLineField;
           
            private System.DateTime sTimeField;
           
            private bool sTimeFieldSpecified;
           
            private string shiftField;
           
            private string siteCodeField;
           
            private string typeField;
           
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
            public string AreaNo {
                get {
                    return this.areaNoField;
                }
                set {
                    this.areaNoField = value;
                }
            }
           
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
            public string DailyCheckTaskID {
                get {
                    return this.dailyCheckTaskIDField;
                }
                set {
                    this.dailyCheckTaskIDField = value;
                }
            }
           
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
            public string Department {
                get {
                    return this.departmentField;
                }
                set {
                    this.departmentField = value;
                }
            }
           
            /// <remarks/>
            public System.DateTime ETime {
                get {
                    return this.eTimeField;
                }
                set {
                    this.eTimeField = value;
                }
            }
           
            /// <remarks/>
            [System.Xml.Serialization.XmlIgnoreAttribute()]
            public bool ETimeSpecified {
                get {
                    return this.eTimeFieldSpecified;
                }
                set {
                    this.eTimeFieldSpecified = value;
                }
            }
           
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
            public string EquipmentNo {
                get {
                    return this.equipmentNoField;
                }
                set {
                    this.equipmentNoField = value;
                }
            }
           
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
            public string PrdLine {
                get {
                    return this.prdLineField;
                }
                set {
                    this.prdLineField = value;
                }
            }
           
            /// <remarks/>
            public System.DateTime STime {
                get {
                    return this.sTimeField;
                }
                set {
                    this.sTimeField = value;
                }
            }
           
            /// <remarks/>
            [System.Xml.Serialization.XmlIgnoreAttribute()]
            public bool STimeSpecified {
                get {
                    return this.sTimeFieldSpecified;
                }
                set {
                    this.sTimeFieldSpecified = value;
                }
            }
           
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
            public string Shift {
                get {
                    return this.shiftField;
                }
                set {
                    this.shiftField = value;
                }
            }
           
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
            public string SiteCode {
                get {
                    return this.siteCodeField;
                }
                set {
                    this.siteCodeField = value;
                }
            }
           
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
            public string Type {
                get {
                    return this.typeField;
                }
                set {
                    this.typeField = value;
                }
            }
        }
        调用引用的WCF服务

        
            [WebMethod]
            public string HelloWorld()
            {
                APPTEST.QueryClass qc = new APPTEST.QueryClass();
                qc.EquipmentNo = "MD010205MX25";
                qc.Type = "Equipment";
                qc.STime = DateTime.Now.AddDays(-30);
                qc.ETime = DateTime.Now;
                qc.STimeSpecified = true;
                qc.ETimeSpecified = true;
                APPTEST.Srv_EASAPP client = new APPTEST.Srv_EASAPP();
                string s = client.GetDailyTask(qc);
                return "Hello World";
            }

  • 相关阅读:
    解惑开源项目协作流程
    结合webpack 一步一步实现懒加载的国际化简易版方案
    SEO优化之——hreflang(多语言网站优化)
    pandas数据分析常用
    多任务: 多进程与多线程
    linux基础知识
    python常用模块之sys, os, random
    递归函数(初级难点)
    内置函数
    函数
  • 原文地址:https://www.cnblogs.com/skyloverdan/p/9395941.html
Copyright © 2011-2022 走看看