title: Posting to WCF Service sending NULL values
body: <p>I'm trying to post to my WCF Service from an iPhone app. I have the app posting to the service and trying to send data in the form of a service data contract in XML like below:</p>
  
  <pre><code>NSData *myPostData = [[NSString stringWithFormat:@"&lt;AddMediaItem xmlns='http://www.example.com'&gt;&lt;Item xmlns:a='http://www.example.com/MediaItem'&gt;&lt;a:MediaType&gt;iPhone&lt;/a:MediaType&gt;&lt;a:Description&gt;Description&lt;/a:Description&gt;&lt;a:Name&gt;Test&lt;/a:Name&gt;&lt;a:ImageType&gt;JPEG&lt;/a:ImageType&gt;&lt;/Item&gt;&lt;/AddMediaItem&gt;"] dataUsingEncoding:NSUTF8StringEncoding];
  
  NSMutableData *myMutablePostData = [NSMutableData dataWithData:myPostData];
  
  [request setPostBody:myMutablePostData];  
  [request setRequestMethod:@"POST"];  
  [request addRequestHeader:@"Content-Type" value:@"application/xml"];  
  
  [request setDidFinishSelector:@selector(uploadFinished:)];
  [request setDidFailSelector:@selector(uploadFailed:)];
  [request setDelegate:self];
  [request startAsynchronous];
  </code></pre>
  
  <p>For testing purposes, I've setup my service to return the data contract that I send to the service. However, when it returns, some of the values seem to be NULLs although from the code above, I am giving them values.</p>
  
  <p>What also seems strange is that the <code>Name</code> data member always has a value, but the other 3 I'm sending return NULL or with the correct values based on the order they appear in the XML I post to the service.</p>
  
  <p>Below is the code for my service contract:</p>
  
  <pre><code>[ServiceContract(Namespace = "http://www.example.com")]
  public interface IImageDiaryService
  {
  
      [OperationContract]
      [WebInvoke(UriTemplate = "AddMediaItem", Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)]
      MediaItem AddMediaItem(MediaItem Item);
  
  }
  </code></pre>
  
  <p>Below is my code for my MediaItem data contract:</p>
  
  <pre><code>[DataContract(Namespace = "http://www.example.com/MediaItem")]
  public class MediaItem
  {
  
      [DataMember]
      public Int32 Id { get; set; }
  
      [DataMember]
      public String Name { get; set; }
  
      [DataMember]
      public String Description { get; set; }
  
      [DataMember]
      public String ImageData { get; set; }
  
      [DataMember]
      public String ImageType { get; set; }
  
      [DataMember]
      public String MediaType { get; set; }
  
  }
  </code></pre>
  
  <p>Do let me know if you need any further code. </p>
  
  <p>Any help is much appreciated.</p>