WCF method parameter order

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?

Answers


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.


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.


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.


Need Your Help

Make lookup tables in Excel/VBA from a list of names with repeats

excel vba

I have a list of names and instances in Excel in one sheet, and a list names and of user ID's in another. I want to make a column that references name and user ID on the instance sheet, however som...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.