In an earlier project, I added a service reference in Visual Studio C# 2010 and the code generated by Studio was this (the third-party web service was probably created with WCF):
System.Guid ServiceFunctionName(out string fileName, out int fileSize, System.Guid fileGuid, bool zip);
This code above matches the function declaration that appears also in the documentation of the service third-party vendor.
Now, for a different project, I added the exact same service reference in a new application, this time in Visual Studio 2012, and the code generated has been refactored into a response object with the original return types and the two out
arguments and a request object with the two arguments that were input arguments in the former function declaration:
AppNamespace.ServiceReferenceName.ServiceFunctionNameResponse ServiceFunctionName(AppNamespace.ServiceReferenceName.ServiceFunctionNameReRequest request);
public ServiceFunctionNameRequest(System.Guid fileGuid, bool zip)
{
this.fileGuid = fileGuid;
this.zip = zip;
}
public ServiceFunctionNameResponse(System.Guid ServiceFunctionNameResult, string fileName, int fileSize)
{
this.ServiceFunctionNameResult = ServiceFunctionNameResult;
this.fileName = fileName;
this.fileSize = fileSize;
}
There is also this comment in the generated code near to the refactored function, which sort of makes sense because the function in question returns 3 values:
// CODEGEN: Generating message contract since the operation has multiple return values.
Why am I getting different function declarations in VS 2010 and VS 2012?
Is this some that I can control someway with some setting in Visual Studio 2012 for Windows Desktop? (I'm a bit uneasy about tweaking generated code)
I finally figured out that the difference in service reference function declarations was caused by the target .NET of the solution.
In one case (VS 2010 C#), target was .NET 4.0 and in the other case (VS 2012 C#) target was .NET 4.5. After the VS 2012 solution service references were added again with .NET 4.0 as target, the function declarations were the same as in VS 2010 C#.