2009-09-25 62 views
1

我在WCF服務爲代表的一組參數無效的一類,C#和WCF - SvcUtil工具不是串正確地產生包裝器[]

[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

假設你正在使用Visual Studio,也有在「添加服務引用」的一些設置 - >「高級」對話框,允許你指定產生集合類型。是集生成的System.Array(默認的,我認爲),或者其他什麼東西?

而且,這部分類似乎並沒有從FaultBase派生的。你或許選擇「添加Web引用」 - 說服Visual Studio來實現經典風格的ASMX Web服務客戶端,而不是一個WCF客戶端?