Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6359737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:33:30+00:00 2026-05-24T23:33:30+00:00

I used XSD2Code to generate C# code from given XSD. This tool generated code

  • 0

I used XSD2Code to generate C# code from given XSD. This tool generated code snipped as below:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")]
    [System.SerializableAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
    [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
    public partial class Orders
    {

        [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 0)]
        public int OrderID {get;set;}
        [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 1)]
        public string Description {get;set;}
     }

Coud some one please guide me with following queires, please

  1. If I leave the above code as it is, does WCF serializes the above class?
    Currently I’m getting this error on wcf test client: “”this Operation is not
    supported in WCF Test Client”.

  2. Do I need to add DataContract and DataMember on top of the above generated codes?

  3. Which option is beter between DataContract Serializer vs XML Serializer
    Thanks you.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:33:31+00:00Added an answer on May 24, 2026 at 11:33 pm
    1. It should work, as long as the contract (either the service contract interface or the operation contract method which uses this type) is marked with the [XmlSerializerFormat] attribute
    2. No – if you decorate the contract with [XmlSerializerFormat], the DataContract/DataMember attributes are ignored (the XML serialization attributes, like the ones in this type, are used instead)
    3. The XmlSerializer allows you to completely control the XML in which the types are serialized; the DataContractSerializer (DCS) doesn’t (it’s more limited). But the DCS has a better performance, so which one is better really depends on your scenario.

    The code below shows a service which uses this type, and it works fine, even with the WcfTestClient.

    public class StackOverflow_7155154
    {
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")]
        [System.SerializableAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
        [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
        public partial class Orders
        {
            [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 0)]
            public int OrderID { get; set; }
            [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 1)]
            public string Description { get; set; }
        }
        [ServiceContract]
        [XmlSerializerFormat]
        public interface ITest
        {
            [OperationContract]
            Orders GetOrders();
        }
        public class Service : ITest
        {
            public Orders GetOrders()
            {
                return new Orders { Description = "My order", OrderID = 1 };
            }
        }
        public static void Test()
        {
            //MemoryStream ms = new MemoryStream();
            //XmlSerializer xs = new XmlSerializer(typeof(Orders));
            //Orders o = new Orders { OrderID = 1, Description = "My order" };
            //xs.Serialize(ms, o);
            //Console.WriteLine(Encoding.UTF8.GetString(ms.ToArray()));
    
            string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
            ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));
            host.AddServiceEndpoint(typeof(ITest), new BasicHttpBinding(), "");
            host.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = true });
            host.Open();
            Console.WriteLine("Host opened");
    
            ChannelFactory<ITest> factory = new ChannelFactory<ITest>(new BasicHttpBinding(), new EndpointAddress(baseAddress));
            ITest proxy = factory.CreateChannel();
    
            Console.WriteLine(proxy.GetOrders());
    
            ((IClientChannel)proxy).Close();
            factory.Close();
    
            Console.Write("Press ENTER to close the host");
            Console.ReadLine();
            host.Close();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I auto generated an xsd file from the below xml and used xsd2code to
I used to have a code that checks any previous element with a corresponding
I used System.Windows.Window.IsActive to detect whether the window is in the foreground and it
I used to code in C language in the past and I found the
I used to compile my asm code with TASM (on winXP) but I had
Used as a scripting language, does Scala have some sort of include directive, or
used to check user input like username not a login account.
Used to develop Portlets and JPS's, so have a dilemma. task: display <h:dataTable> only
Used SSH Tunnel to route the traffic addressed to server1:port1 to server2:port2. Now,the problem
Used to be quite happy with the Ctrl + Shift + F10 shortcut in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.