0

In my WCF web service, I have the following interface:

[ServiceContract]
public interface ITestService
{
    [OperationContract]
    void TestMethod(out int param1, out int param2);
}

When I add the service reference in the client side, the generated client method does not match correctly the original signature, it maps one of the out parameter as the method return. I have to call it this way:

using (var client = new TestServiceClient())
{
    int param2;
    int param1 = client.TestMethod(out param2);
}

Is there any way I can "force" the proxy to be generated being faithful to the original method signatures?

Doug
  • 6,322
  • 3
  • 29
  • 48
  • Also see: http://stackoverflow.com/questions/11294971/how-can-i-prevent-an-out-parameter-to-end-up-return-parameter-in-a-wcf-web-servi – JW Lim May 03 '14 at 04:06

3 Answers3

2

I'd consider to change your service to return data structure with 2 properties, and return it from your operation, instead of using out parameters.

evgenyl
  • 7,837
  • 2
  • 27
  • 32
1

I believe this is a limitation of the proxy generation code. You'd have to edit the generated proxy code in the client in order to change this.

Peter Ritchie
  • 35,463
  • 9
  • 80
  • 98
0

Technically it IS being faithful. If you dig into the Reference.cs, you will see that when the proxy calls your service, the call is the same. However, the proxy or "wrapper" that calls the service decided to "wrap" your service call differently.

The only way to make the proxy itself keep the same signature is to write it yourself. This is EXACTLY the same issue people have when reflecting a DLL. Sure you can reflect it and get the "source code", but the reflected code will be different than the original source, although the functionality will be the same.

Jeff
  • 972
  • 5
  • 11