c# - 为什么我的 wcf web 服务引用中有额外的参数?

标签 c# wcf web-services

我正在尝试将 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/

相关文章:

javascript - 如何在 enyo 中使用 SOAP?

php - 在 Controller 中使用 NuSOAP 的 Laravel 不工作

c# - 使用 c# 的亚马逊市场网络服务 (amazon mws)

c# - 是否检查null

c# - 基于 REST 的 WCF 身份验证

c# - 从 Android KSoap2 使用在 Mono 上运行的 WCF Soap 服务

java - 在不使用 Web 服务器的情况下部署 Java Web 服务

c# - .net 中 ObservableCollection 的用途是什么?

c# - 如何使用 LINQ 转置二维集合中的维度?

wcf - 在服务器上启用托管 WCF 服务的跟踪