开发者

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 so开发者_Python百科urceDataQuery)
    {

        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?


Try using DataContract instead. It might solve your problem

[DataContract]
      public class SourceDataQuery
        {

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

            ....
        }


Try to wrap the serviceclient object in the IService interface, for example write:

ServiceReference1.IService1 serviceclient = new ServiceReference1.Service1Client();

instead of

ServiceReference1.Service1Client serviceclient = new ServiceReference1.Service1Client();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜