Search code examples
c#wsdlsvcutil.exe

svcUtil not generating the same output from WSDL


I'm trying to use svcutil to generate a client contract files for my client from a WSDL file, that only has minor changes (added values to enumerables) - I checked using several DIFF tools.

But the generated contract classes are different - the main thing being that the old contract classes had the Input and Output of the tasks for client wrapped in "Request" and "Response" objects, whereas now the input and output is "left plain".

Example of old Generated code:

///attributes left out for brevity, they are the same in both
public interface IServiceWS
{

    ///left out for brevity, same in both
    Contracts.VyhledejVozidloIDResponse VyhledejVozidloID(Contracts.VyhledejVozidloIDRequest request);

Whereas now the generated code is:

///attributes left out for brevity, they are the same in both
public interface IServiceWS
{
   ///left out for brevity, same in both
   Contracts.VozidloStructure[] VyhledejVozidloID(Contracts.UzivatelInfoStructure UzivatelInfo, int[] VozidloID);

And the code for generating the contract:

@set SVCUTIL="%WindowsSDK_ExecutablePath_x64%\SvcUtil.exe"
@set SERVICE=http://localhost/ServiceWS/ServiceWS.wsdl

%SVCUTIL% /namespace:*,Contracts /out:Contracts.cs ^
    %SERVICE%

I'm pretty sure the code for generating the old contract is the same, but the old version was generated two years ago on an older visual studio with older .net framework.

The old Contracts.VyhledejVozidloIDResponse contains the Contracts.VozidloStructure[].

Contracts.VyhledejVozidloIDRequest wrapper objects contains the the now unwrapped stuff Contracts.UzivatelInfoStructure UzivatelInfo and int[] VozidloID.

What should I change to get it generated in the old style?


Solution

  • In the end I solved my own problem.

    The answer for me revealed itself after I finally found a bit of documentation on https://learn.microsoft.com/cs-cz/dotnet/framework/wcf/servicemodel-metadata-utility-tool-svcutil-exe

    And it was using the /wrapped argument. The output was still not exactly the same (as it generated much more wrapper classes for a lot of stuff), but I could work around it, unlike working around unwrapped request/response parameters, that would require me to change the whole abstract client logic we have in our project.