title: WCF XMLserialization of nested composite objects
body: <p>Hi I have a service contract and in its implementation I am trying to write the request parameters it receives in a text file. Here a composite object of 'TypeA a' is passed as a parameter.</p>
  
  <pre><code>        namespace WebService
  {
      // NOTE: If you change the interface name "IRequestStatusChanged" here, you must also update the reference to "IRequestStatusChanged" in App.config.
      [ServiceContract]
      public interface IRequestStatusChanged
      {
          [OperationContract]
          Input StatusChanged(Input In);
  
      }
  
      [Serializable] [DataContract]
      public class Input
      {
          [DataMember]
          RequestStatus RS = new RequestStatus();
  
      }
  
      [Serializable] [DataContract]
      public class RequestStatus
      {
          [DataMember]
          RequestToken RT = new RequestToken();
  
          [DataMember]
          public String State
  
      }
      [Serializable] [DataContract]
      public class RequestToken
      {
          [DataMember]
          public string Id;
      }
  }
  
  Implementation of contract
  
  namespace WebService
  {
      // NOTE: If you change the class name "RequestStatusChanged" here, you must also update the reference to "RequestStatusChanged" in App.config.
      public class RequestStatusChanged : IRequestStatusChanged
      {
          public Input StatusChanged(Input In)
          {
  
  
             /* IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
              Stream outfile = new FileStream(@"C:\test.txt", FileMode.Open,FileAccess.Write);
              formatter.Serialize(outfile, In);
              outfile.Close(); */
  
  
              XmlSerializer serializer = new XmlSerializer(typeof(Input));
              TextWriter TW = new StreamWriter(@"c:\test.xml");
              serializer.Serialize(TW, In);
              TW.Close();
  
              return In;
          }
  
      }
  }
  </code></pre>
  
  <p>earlier I tried IFORMATTER to serialize the object and write it to text file but it is not human readable, so I tried xml serialization.</p>
  
  <p>When I check the XML file written it only has tags for 'TypeA' object and does not write 'TypeB' and 'TypeC' objects to the file. I have marked all the classes as [Serializable] in the service contract. I want to write all the parameters received in the text or xml format to a file so that they are readable (kind of a log file).</p>