我正在尝试将 ASP.Net Web 服务转换为 WCF 应用程序。客户端位于不支持 WCF 的 .Net Compact Framework 上,因此我需要确保 WCF 继续支持 ASP 样式的 Web 服务。当我在 Visual Studio 中添加 Web 服务引用时,生成的代理类的方法有额外的参数。
例如,如果一个方法被定义为:
public void GetEmpInfo(int empNo)
该方法将在代理类中显示为:
public void GetEmpInfo(int empNo, bool empNoSpecified)
是什么原因导致的,我该如何停止?
最佳答案
看看这个 blog post ...
Where did these extra boolean “specified” members come from and what do they do? The answer is the schema that the WCF data contract serializer generates by default. Because of the way its versioning model works, the serializer generates all data members as optional elements. The older web services stack, ASP.NET Web Services (“ASMX”), uses a different serializer, the XmlSerializer, which maintains full schema and XML fidelity. The XmlSerializer maps all optional elements to two members: one represents the data itself, and one specifies whether or not the data is actually present – this is the “xxxSpecified” member. These xxxSpecified members must be set to true to enable the serialization of the corresponding “actual data” members.
关于c# - 为什么我的 wcf web 服务引用中有额外的参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/997545/