none
Client code generation problems using SvcUtil.exe

    Question

  • Hi All,

    I have a problem with the Svcutil client code generation.

    Below is the generated code using SvcUtil for Service Contract:

     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
        [System.ServiceModel.ServiceContractAttribute(Namespace="", ConfigurationName="Proxy.SomeContractName")]
        public interface SomeContractName {
           
            // CODEGEN: Generating message contract since element name someName from namespace somenamespace is not marked nillable
            [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="" +
                "")]
            Client.Proxy.StrongType(Return type of the method) SomeMethodName(Client.Proxy.Strong Type (Input Parameter) request);
           
          
        }

    So SvcUtil is generating message Contract. Also the generated file has duplicates. Code below describes:

    [global:Tongue Tiedystem.ComponentModel.BrowsableAttribute(false)]
            public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
                get {
                    return this.extensionDataField;
                }
                set {
                    this.extensionDataField = value;
                }
            }
           
            [System.Runtime.Serialization.DataMemberAttribute(Name="ExtensionData", EmitDefaultValue=false)]
            public Client.Proxy.ExtensionDataObject ExtensionData1 {
                get {
                    return this.ExtensionData1Field;
                }
                set {
                    if ((object.ReferenceEquals(this.ExtensionData1Field, value) != true)) {
                        this.ExtensionData1Field = value;
                        this.RaisePropertyChanged("ExtensionData1");
                    }
                }
            }


    I try testing the service by generating a sample Xml file from XSD and deserialize to get the specific types

    When I created the serializer and mention name of the type. The following exception is thrown : There was an error reflecting type 'Client.Proxy.ClassNameHere."

    {"Types 'Client.Proxy.ExtensionDataObject' and 'System.Runtime.Serialization.ExtensionDataObject' both use the XML type name, 'ExtensionDataObject', from namespace ''. Use XML attributes to specify a unique XML name and/or namespace for the type."}
        [System.InvalidOperationException]: {"Types 'Client.Proxy.ExtensionDataObject' and 'System.Runtime.Serialization.ExtensionDataObject' both use the XML type name, 'ExtensionDataObject', from namespace ''. Use XML attributes to specify a unique XML name and/or namespace for the type."}
        Data: {System.Collections.ListDictionaryInternal}
        HelpLink: null
        InnerException: null
        Message: "Types 'Client.Proxy.ExtensionDataObject' and 'System.Runtime.Serialization.ExtensionDataObject' both use the XML type name, 'ExtensionDataObject', from namespace ''. Use XML attributes to specify a unique XML name and/or namespace for the type."
        Source: "System.Xml"
        StackTrace: "   at System.Xml.Serialization.XmlReflectionImporter.GetTypeMapping(String typeName, String ns, TypeDesc typeDesc, NameTable typeLib, Type type)\r\n   at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a, RecursionLimiter limiter)\r\n   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)"
        TargetSite: {System.Xml.Serialization.TypeMapping GetTypeMapping(System.String, System.String, System.Xml.Serialization.TypeDesc, System.Xml.Serialization.NameTable, System.Type)}


    Anybody experienced the same problem when generating the client code using SvcUtil

    Thanks








    Tuesday, September 16, 2008 1:43 AM

All replies