WCF 代理类中缺少方法参数
我有一个 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 对象是在代理类中正确生成的。
知道为什么缺少输入参数吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 DataContract 代替。它可能会解决你的问题
Try using DataContract instead. It might solve your problem
尝试将serviceclient对象包装在IService接口中,例如写:
而不是
Try to wrap the serviceclient object in the IService interface, for example write:
instead of