none
VS 2008 generates code with errors from WSDL

    Question

  • Hello!
    I hope, I'm posting in the right forum. I have a Web Service (Java, Apache CXF) for which I want to create a client with C#. Therefore I added a Service Reference in VS 2008 from the existing WSDL [1]. However, I can't compile my program after that. I get two errors from the generated code:

    1) The type WindowsFormsApplication1.ServiceReference1.DataMiningException" already contains a definition for 'PropertyChanged'
    2) The type WindowsFormsApplication1.ServiceReference1.DataMiningException" already defines a member called 'RaisePropertyChanged' with the same parameter types

    Now I'm wondering what the reason for this error may be. Is there a problem with the WSDL, am I doing something completely wrong or is there a bug in VS 2008?

    I'd be grateful for any help you can give me to solve this problem. Thanks in advance.

    Best regards,
    gertschi

    [1] http://www.gerhard-schlager.at/temp/ClassifierService.wsdl
    Monday, March 10, 2008 7:47 PM

Answers

  • Ok i duplicated this error.  From a look at the generated class therea re 2 partial classes for DataMiningException.  Both of these are adding the PropertyChanged and RaisePropertyChanged methods which is why you are getting the error.

    You have it declared as a possible fault exception and as a class in the WSDL.  So visual studio is generating 2 classes for it.  This is probably not what you are expecting.  So the WSDL is not what Visual studio is expecting. You could call this a bug in the WSDL or a bug in Visual studio.

    If you go into your refernce.cs geneated proxy class and jsut remove the first "partial class DataMiningException" (its the first class in the file).  All should work well.
    Monday, March 10, 2008 8:22 PM
    Moderator

All replies

  • Ok i duplicated this error.  From a look at the generated class therea re 2 partial classes for DataMiningException.  Both of these are adding the PropertyChanged and RaisePropertyChanged methods which is why you are getting the error.

    You have it declared as a possible fault exception and as a class in the WSDL.  So visual studio is generating 2 classes for it.  This is probably not what you are expecting.  So the WSDL is not what Visual studio is expecting. You could call this a bug in the WSDL or a bug in Visual studio.

    If you go into your refernce.cs geneated proxy class and jsut remove the first "partial class DataMiningException" (its the first class in the file).  All should work well.
    Monday, March 10, 2008 8:22 PM
    Moderator
  • Any more thoughts on this?  I am curious as to if this answer is suitable or if there is more going on here.  I can see other people having this same issue over time.
    Tuesday, March 11, 2008 5:05 PM
    Moderator
  • Hello Dan!

    Thanks for your fast response. I just tested your solution and it works. Well, at least I do not get any other compiler errors anymore. :-)

    Since the WSDL has been generated by Apache CXF (it's a "Java first" program) I'll contact the developers of CXF. Maybe they can tell me why it exists two times in the WSDL ...
    Tuesday, March 11, 2008 9:57 PM
  • Well, now I get runtime errors when I try to execute my web methods. For example: When I call the client's function getAlgorithmList() a CommunicationException gets thrown. The following is just a poor translation since I don't know how I can get rid of the German error messages (even though my VS is English).

    "Unable to generate temporary classes (result=1).
    Cannot convert type double?[] to double
    Cannot implicitly convert type double to double?[]"

    I guess there are some other problems within the generated code or I'm doing something completly wrong.
    Tuesday, March 11, 2008 10:36 PM
  • Any updates on this bug? anyone?
    Monday, October 26, 2009 6:41 PM
  • I have the same issue but I notice the two different versions of the SOAPException generated code are for different references
    ("System.Xml", "2.0.50727.3082" and "System.Runtime.Serialization", "3.0.0.0")...

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3082")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:connections.ispectrum.summitsite.com")]
        public partial class SOAPException : object, System.ComponentModel.INotifyPropertyChanged
        {
    
            private string messageField;
    
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 0)]
            public string message
            {
                get
                {
                    return this.messageField;
                }
                set
                {
                    this.messageField = value;
                    this.RaisePropertyChanged("message");
                }
            }
    
            public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
    
            protected void RaisePropertyChanged(string propertyName)
            {
                System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
                if ((propertyChanged != null))
                {
                    propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
                }
            }
        }
    and then here is the other....

    [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
        [System.SerializableAttribute()]
        [System.Xml.Serialization.XmlSchemaProviderAttribute("ExportSchema")]
        [System.Xml.Serialization.XmlRootAttribute(IsNullable=false)]
        public partial class SOAPException : object, System.Xml.Serialization.IXmlSerializable, System.ComponentModel.INotifyPropertyChanged {
            
            private System.Xml.XmlNode[] nodesField;
            
            private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("SOAPException", "urn:connections.ispectrum.summitsite.com");
            
            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));
                }
            }
        }
    they are both listed as references in my project. I initially tried renaming some of the methods and eventhandlers but that led to to a host of other flags that were thrown and I am not sure I want to go down that rabbit hole right now.  Has anyone else run across a reasonable solution to this? 
    Tuesday, March 09, 2010 6:19 PM
  • Did you ever get this resolved? We're seeing the same thing here while trying to add a service reference to a WCF service.
    Wednesday, June 09, 2010 6:09 PM
  • You can fix this error creating a NAMESPACE into a generated file.

    I solve my problem create a NAMESPACE, eg:

    Error 3 The type 'PurchaseRequest_Get' already contains a definition for 'superbuyHeaderField'

    So, I create a diferent NAMESPACE in both files and put into the class with the same name.

    THE COMAND is: wsdl /n:VSTUBOS PurchaseRequest_Get.wsdl

    The option n create a namespace like above:

    namespace VSTUBOS

    {

     

        /// <remarks/>

        [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]

        [System.SerializableAttribute()]

        [System.Diagnostics.DebuggerStepThroughAttribute()]

        [System.ComponentModel.DesignerCategoryAttribute("code")]

        [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://vstubos.com/ecc/purchasing/PurchaseRequestMngt")]

        public partial class PurchaseRequest_Get

        {

     

            private SuperbuyHeader superbuyHeaderField;

     

            /// <remarks/>

            [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]

            public SuperbuyHeader SuperbuyHeader

            {

                get

                {

                    return this.superbuyHeaderField;

                }

                set

                {

                    this.superbuyHeaderField = value;

                }

            }

        }

    (.................)

     

    Important: If the problem happen whith the classses whith the same namespace, you can delete some of the class in the one of files. This is another option.

    Sorry, my english isn't so good!

     

     



    Thursday, August 18, 2011 9:05 PM