Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 219
Abel Avatar asked Jul 02 '12 13:07

Abel


1 Answers

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.

like image 55
b_levitt Avatar answered Oct 21 '22 00:10

b_levitt