如何防止输出参数最终在 WCF Web 服务中返回参数? [英] How can I prevent an out-parameter to end up return parameter in a WCF web service?

查看:20
本文介绍了如何防止输出参数最终在 WCF Web 服务中返回参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的合同如下所示:

If my contract looks as follows:

[OperationContract]
void DoSomething(int id, out string moreInfo);

最终看起来像:

string DoSomething(int id);

当您导入 Web 服务引用时.是否可以影响参数顺序的自动转换?在函数签名的开头找到所有输出参数已经令人惊讶了,但这仍然可行,但我们希望 void-methods 继续作为 void-methods.或者这是 SOAP 限制?

when you import a web service reference. Is it possible to influence the auto-conversion of the order of the parameters? It was already surprising to find all out-parameters at the beginning of the function signature, but that was still workable, but we'd like void-methods to continue being void-methods. Or is this a SOAP limitation?

推荐答案

它似乎基于 WSDL 限制:http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/48b5992f-f7bd-4b67-8299-514d1780fa9a

It appears to be based on a WSDL limitation: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/48b5992f-f7bd-4b67-8299-514d1780fa9a

WSDL 不显示原始方法签名;相反,它显示输入参数作为一个组,输出参数作为另一个组.

WSDL does not show the original method signature; instead, it shows the input parameters as a group and the output parameters as another group.

无法将返回值与输出参数分开的限制在于 WSDL.但这意味着我认为 void 方法的限制将成为 svcutil.exe 的一部分.没有理由不能在 svcutil 上进行开关以不将第一个输出移动到返回值,但这将是对 ms connect 功能的请求.

The limitation of not being able to separate return values from out parameters is in the WSDL. But that would mean the limitation of a void method would be part of svcutil.exe I think. There's no reason why there can't be a switch on svcutil to not move the first output to a return value, but that would be a request for a feature on ms connect.

如果您的问题是一致性,您可以返回一个简单的状态 int 或 bool 而不是 void,但如果您已经有几十种方法,我敢肯定这不是一个完美的答案.

Rather than void, you could return a simple status int or bool if your issue is consistency, but I'm sure that's not a perfect answer if you already have dozens of methods.

这篇关于如何防止输出参数最终在 WCF Web 服务中返回参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆