How can I prevent an out-parameter to end up return parameter in a WCF web service?

你离开我真会死。 提交于 2019-12-29 07:36:21

问题


If my contract looks as follows:

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

this ends up looking like:

string DoSomething(int id);

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?


回答1:


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 does not show the original method signature; instead, it shows the input parameters as a group and the output parameters as another group.

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.

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.



来源:https://stackoverflow.com/questions/11294971/how-can-i-prevent-an-out-parameter-to-end-up-return-parameter-in-a-wcf-web-servi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!