At work, we have recently been porting our internal web framework into .net 6. Yes, we are late to the party on this, for reasons. Suffice it to say I currently work in an inherently risk averse industry.
Anyway, one part of the framework is responsible for getting reports from SSRS.
The way it did this is to use a wrapper class around a SOAP client generated from good old ReportService2005.asmx?wsdl
, using our faithful friend svcutil.exe
. The wrapper class used some TaskCompletionSource
magic on the events in the client to make the client.LoadReportAsync
and the other *Async
methods actually async, as the generated client was not truely async.
Fast forward to the modern times, and we need to upgrade it. How do we do that?
Obviously, Microsoft are a step ahead: svcutil
has a dotnet version - dotnet-svcutil
. We can install it and get going:
Once installed, we can call it against the endpoint:
In our wrapper class, the initialisation of the client has to change slightly, because the generated client is different to the original svcutil
implementation. Looking at the diff between the two files, it’s because the newer version of the client users more modern .net functionality.
The wrapper class constructor has to be changed slightly:
Then, the code which actually generates the report can be updated to remove all of the TaskCompletionSource
, which actually simplifies it a great deal:
You can then do whatever you like with the byte[]
, like return it in an IActionResult
or load it into a MemoryStream
and write it to disk as the file.