C#和WCF - svcutil没有为string []正确生成包装器

时间:2009-09-25 13:35:09

标签: c# wcf svcutil.exe

我在wcf服务中有一个类来表示一组无效参数,

[DataContract(Namespace = WebServiceNamespace.WsNamespace)]
public class InvalidParameterFault : FaultBase
{
    public override string GetReason()
    {
        return Resources.OneOrMoreParametersInvalid;
    }                       

    [DataMember]
    public string[] InvalidParameters { get; set; }       

    public InvalidParameterFault()
    {            
    }        
}

(部分)合同定义为,

[FaultContract(typeof(InvalidParameterFault))]
[OperationContract]        
uint RegisterIndividual(RegisterIndividualPayload payload);

当我向我的测试项目添加服务引用时,它创建的包装器如下所示(与原始定义完全不同)。有谁知道为什么这是??????????

[System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.SerializableAttribute()]
    [System.Xml.Serialization.XmlSchemaProviderAttribute("ExportSchema")]
    public partial class InvalidParameterFault : object, System.Xml.Serialization.IXmlSerializable, System.ComponentModel.INotifyPropertyChanged {

        private System.Xml.XmlNode[] nodesField;

        private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("InvalidParameterFault", "http://schemas.facecode.com/webservices/2009/08/");

        public System.Xml.XmlNode[] Nodes {
            get {
                return this.nodesField;
            }
            set {
                if ((object.ReferenceEquals(this.nodesField, value) != true)) {
                    this.nodesField = value;
                    this.RaisePropertyChanged("Nodes");
                }
            }
        }

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        public void ReadXml(System.Xml.XmlReader reader) {
            this.nodesField = System.Runtime.Serialization.XmlSerializableServices.ReadNodes(reader);
        }

        public void WriteXml(System.Xml.XmlWriter writer) {
            System.Runtime.Serialization.XmlSerializableServices.WriteNodes(writer, this.Nodes);
        }

        public System.Xml.Schema.XmlSchema GetSchema() {
            return null;
        }

        public static System.Xml.XmlQualifiedName ExportSchema(System.Xml.Schema.XmlSchemaSet schemas) {
            System.Runtime.Serialization.XmlSerializableServices.AddDefaultSchema(schemas, typeName);
            return typeName;
        }

        protected void RaisePropertyChanged(string propertyName) {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null)) {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }

1 个答案:

答案 0 :(得分:1)

假设您使用的是Visual Studio,“添加服务引用”中有一些设置 - > “高级”对话框,允许您指定生成的集合的类型。是否设置为生成System.Array(默认,我认为)或其他什么?

此外,这个部分类似乎根本不是从FaultBase派生的。您是否选择了“添加Web引用” - 说服Visual Studio实现经典样式的ASMX Web服务客户端而不是WCF客户端?