wcfmessageproxy-classesmessagecontract

Method parameter is missing in WCF proxy class


I have a WCF method defined as below:

[OperationContract]
Message GetSourceData(SourceDataQuery sourceDataQuery);

And actual implementation is something like this:

public Message GetSourceData(SourceDataQuery sourceDataQuery)
    {

        IEnumerable<ExportRow> sourceData = repo.GetData();

        var customBodyWriter = new CustomBodyWriter(sourceData);
        var message = Message.CreateMessage(MessageVersion.Soap11, "GetSourceData", customBodyWriter);

        return message;
    }

SourceDataQuery object:

[MessageContract]
public class SourceDataQuery
{
    [MessageBodyMember]
    public int DataSourceId { get; set; }

    [MessageBodyMember]
    public int[] FiledIds { get; set; }

    [MessageBodyMember]
    public string Filter { get; set; }

    [MessageBodyMember]
    public string Sort { get; set; }
}

My problem is when I add this WCF service to another project and create a proxy by adding a service reference, my proxy class have a GetSourceData method but its input paramater is missing. It doesnt take any parameter.. I can see that SourceDataQuery object is generated within proxy class correctly though.

Any idea why input parameter is missing?


Solution

  • Try using DataContract instead. It might solve your problem

    [DataContract]
          public class SourceDataQuery
            {
    
                [DataMember]
                public int DataSourceId { get; set; }
    
                ....
            }