WCF object parameter loses values

Posted by Josh on Stack Overflow See other posts from Stack Overflow or by Josh
Published on 2009-08-10T15:23:18Z Indexed on 2010/04/09 8:03 UTC
Read the original article Hit count: 390

Filed under:
|
|

I'm passing an object to a WCF service and wasn't getting anything back. I checked the variable as it gets passed to the method that actually does the work and noticed that none of the values are set on the object at that point. Here's the object:

[DataContract]
public class Section {

    [DataMember]
    public long SectionID { get; set; }

    [DataMember]
    public string Title { get; set; }

    [DataMember]
    public string Text { get; set; }

    [DataMember]
    public int Order { get; set; }
}

Here's the service code for the method:

[OperationContract]
public List<Section> LoadAllSections(Section s) {
    return SectionRepository.Instance().LoadAll(s);
}

The code that actually calls this method is this and is located in a Silverlight XAML file:

SectionServiceClient proxy = new SectionServiceClient();
proxy.LoadAllSectionsCompleted += new EventHandler<LoadAllSectionsCompletedEventArgs>(proxy_LoadAllSectionsCompleted);
 Section s = new Section();
 s.SectionID = 4;
 proxy.LoadAllSectionsAsync(s);

When the code finally gets into the method LoadAllSections(Section s), the parameter's SectionID is not set. I stepped through the code and when it goes into the generated code that returns an IAsyncResult object, the object's properties are set. But when it actually calls the method, LoadAllSections, the parameter received is completely blank. Is there something I have to set to make the proeprty stick between method calls?

© Stack Overflow or respective owner

Related posts about wcf

Related posts about parameters