wcf - WCF 代理类中缺少方法参数

标签 wcf message proxy-classes messagecontract

我有一个 WCF 方法定义如下:

[OperationContract]
Message GetSourceData(SourceDataQuery sourceDataQuery);

实际的实现是这样的:

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 对象:

[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; }
}

我的问题是,当我将此 WCF 服务添加到另一个项目并通过添加服务引用创建代理时,我的代理类具有 GetSourceData 方法,但缺少其输入参数。它不需要任何参数。我可以看到 SourceDataQuery 对象是在代理类中正确生成的。

知道为什么缺少输入参数吗?

最佳答案

尝试使用 DataContract 代替。它可能会解决您的问题

[DataContract]
      public class SourceDataQuery
        {

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

            ....
        }

关于wcf - WCF 代理类中缺少方法参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5160133/

相关文章:

python - 在 Python 中代理一个类

jsp - 使用 PayPal 取消时选择不同的付款方式

python - protobuf嵌入的消息会导致额外的字节,这是分隔符吗?

wcf - WCF/CaSTLe 内存泄漏

wcf - Azure 可以与 Amazon 互操作吗?

java - 如何更改默认的 "Validation Error: Value is not valid"消息?

java - 在 Java 中检索代理调用对象的接口(interface)类

c# - 如何拦截来自 C# 客户端 Web 代理的出站和入站 Soap 消息

c# - VS 2012 在错误的线程上中断

c# - 我无法向 WCF 服务发送超过 13 Mb 的数据(超出最大请求长度)