WCF: WSDL-first approach: Problems with generating fault types

前端 未结 2 1312
你的背包
你的背包 2021-02-06 15:05

I\'m currently in the process of creating a WCF webservice which should be compatible with WS-I Basic Profile 1.1. I\'m using a wsdl-first approach (actually for the first time)

2条回答
  •  Happy的楠姐
    2021-02-06 15:58

    I can give you an example of a fault that is being correctly generated for me through svcutil (with /useSerializerForFaults):

    
      
        
          
          
        
      
    
    

    Is it possible that you are simply missing the namespace for your types?

    This is the generated code:

    /// 
    [System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "3.0.4506.2152")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://myproduct.mycompany.com/")]
    public partial class MyError
    {
    
      // other stuff
    
      private string descriptionField;
    
      /// 
      [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 1)]
      public string description
      {
        get
        {
          return this.descriptionField;
        }
        set
        {
          this.descriptionField = value;
        }
      }
    }
    

    And this is my full svcutil cmd line statement (note that I am generating a service reference for a given existing service - but it shouldn't make much of a difference in terms of code generation):

    svcutil /t:code /out:C:\MyRepository\GeneratedCode\MyServiceReference.cs /n:*,myproduct.mycompany.servicereference /UseSerializerForFaults C:\MyRepository\*.wsdl C:\MyRepository\*.xsd /config:C:\MyRepository\GeneratedCode\MyServiceReference.config
    

提交回复
热议问题