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

  • Home
  • SEARCH
  • 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 8143851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:13:23+00:00 2026-06-06T13:13:23+00:00

I am developing a WCF service which will be consumed by multiple different client

  • 0

I am developing a WCF service which will be consumed by multiple different client applications. In order to make one functionality work, the server needs to read an XML file into a C# DataContract which is then passed on to the concerned client. As far as I understand from the MSDN website, this is possible but I couldn’t find any complete examples. In particular, the website talks about a ‘stream’ parameter which I don’t quite get yet.

My data contract has one property field which is a list of another data contract which has multiple simple property fields.

e.g.

    [DataContract]
    public class MyClass1 {
        [DataMember]
        public string name;
        [DataMember]
        public int age;
    }

    [DataContract]
    public class MyClass2 {
        [DataMember]
        public List<MyClass1> myClass1List;
    }

My classes look something like this.

  • 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-06-06T13:13:25+00:00Added an answer on June 6, 2026 at 1:13 pm

    Here is an example

    MyClass1 obj = new MyClass1();
    DataContractSerializer dcs = new DataContractSerializer(typeof(MyClass1));
    
    using (Stream stream = new FileStream(@"C:\tmp\file.xml", FileMode.Create, FileAccess.Write))
    {
        using (XmlDictionaryWriter writer = 
            XmlDictionaryWriter.CreateTextWriter(stream, Encoding.UTF8))
        {
            writer.WriteStartDocument();
            dcs.WriteObject(writer, obj);
        }
    }
    

    Books b = new Books();
    
    DataContractSerializer dcs = new DataContractSerializer(typeof(Books));
    
    try
    {
        Stream fs = new FileStream(@"C:\Users\temelm\Desktop\XmlFile.xml", FileMode.Create, FileAccess.Write);
    
        XmlDictionaryWriter xdw = XmlDictionaryWriter.CreateTextWriter(fs, Encoding.UTF8);
        xdw.WriteStartDocument();
        dcs.WriteObject(xdw, b);
        xdw.Close();
        fs.Flush();
        fs.Close();
    }
    catch (Exception e)
    {
        s += e.Message + "\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a WCF service which can be consumed by mobile applications to
I'm developing a web-service using WCF, which I want to access using a client
We are developing a selfhosted WCF service host which will be loading services dynamically
I am developing services which will be consumed by many different platforms like Java,PHP,C
I am developing a WCF service that can be consumed by ASP.NET applications where
I'm developing a WPF Client which interacts with a WCF Web Service which persists
I'm developing a WCF service wich will be consumed by a Java application (via
I'm developing an Android client for a WCF service. There is a windows app
We're in the process of developing a WCF REST web service which just receives
I am developing a RESTful WCF service which I then want to consume from

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.