Home All Groups Group Topic Archive Search About

Serialization of the class with parameterized constructor

Author
17 Jul 2006 1:13 PM
Stan
Although this issue came up in the web service, I believe it is related to
serialization in general.

This is my web service interface definition:

========

public class HistoryAttribute
    {
        private int key;
        private string value;

        public HistoryAttribute()
        {
            key = -1;
            value = string.Empty;
        }

        public HistoryAttribute(int key, string value)
        {
            this.key = key;
            this.value = value;
        }
    }

    [WebServiceBinding(
        Name = "ReportService",
        Namespace = "http://PC.WS2",
        ConformsTo = WsiProfiles.BasicProfile1_1,
        EmitConformanceClaims = true)]
    interface IProHistoryService
    {
        [WebMethod]
        void Record(HistoryAttribute[] attributeList);
    }

===================

HistoryAttribute class has parameterized constructor:

        public HistoryAttribute(int key, string value)
        {
            this.key = key;
            this.value = value;
        }


Everything compiles fine, but when a proxy class is generated by WSDL
utility, this constructor is missing:

=======================

   [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://PC.WS2")]
    public partial class HistoryAttribute {

        private int keyField;
        private string valueField;

    }
=============


Only first, default constor is there, and again, no error or warrnings.

I tried to hack it and put parameterized constructo manually, but then I got
an error message during calling the webservice.

Is there a way around it? Maybe there is an attribute I need to use?

Thanks,

-Stan

AddThis Social Bookmark Button