我的 ASMX 代理方法中的这些额外参数是什么?

发布于 2024-08-21 12:56:37 字数 345 浏览 2 评论 0原文

如果我将来自 .NET 1.1 客户端的 Web 引用添加到 WCF 服务,则客户端生成的代理方法将包含一个以每个服务方法参数的后缀“指定”结尾的额外参数,例如,

[OperationContract]
string HelloWorld(string foo, int bar);

结果为:

Service1.HelloWorld(string foo, bool fooSpecified, int bar, bool barSpecified);

我的服务参数是' t 是可选的,那么客户端的这些额外参数是什么,我怎样才能摆脱它们呢?

If I add a web reference from a .NET 1.1 client to a WCF service, the proxy methods generated at the client contain an extra parameter ending with the suffix 'Specified' for each service method parameter, e.g.

[OperationContract]
string HelloWorld(string foo, int bar);

results in:

Service1.HelloWorld(string foo, bool fooSpecified, int bar, bool barSpecified);

My service parameters aren't optional so what are these extra parameters at the client, and how can I get rid of them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

掌心的温暖 2024-08-28 12:56:37

这是由于 WCF 和 ASMX Web 服务中使用的序列化机制存在差异造成的。
为了避免额外的参数,您必须在 ServiceContract 上指定 XmlSerializerFormat 属性。

要添加,请阅读以下内容:
http:// /msmvps.com/blogs/windsor/archive/2008/05/17/calling-wcf-services-from-net-1-1.aspx

This is due to a difference in the serialization mechanisms used in WCF and ASMX Web Services.
To avoid extra params you must specify XmlSerializerFormat attribute on ServiceContract.

for add read this:
http://msmvps.com/blogs/windsor/archive/2008/05/17/calling-wcf-services-from-net-1-1.aspx

画▽骨i 2024-08-28 12:56:37

问题在于允许不存在值类型的参数。如果没有 *specified 参数,.NET 1.1 无法指定这一点。它们需要设置为 true 以指示正在发送相应的参数。

The issue is with parameters of a value type when they are permitted to be absent. .NET 1.1 has no way to specify this without the *specified parameters. They need to be set to true to indicate that the corresponding parameter is being sent.

極樂鬼 2024-08-28 12:56:37

.NET 1.1 Web 服务没有 null 的概念,因此 WCF 会为您生成这些额外的属性。 fooSpecified = false 表示 foo 实际上为 null。

.NET 1.1 Web services don't have a concept of null so WCF is generating these extra properties for you. fooSpecified = false means foo is really null.

殊姿 2024-08-28 12:56:37

您可能需要说明您的参数必需的

[OperationContract] 
string HelloWorld([RequiredDataParameter] string foo,
                  [RequiredDataParameter] int bar);

You probably need t osay that your parameters are required

[OperationContract] 
string HelloWorld([RequiredDataParameter] string foo,
                  [RequiredDataParameter] int bar);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文