I have a collection of related webservices that share some of the types between them, notably the "token" generated by the TokenService.
When using "add reference" in Visual Studio, proxy classes are generated and many classes, such as the Token class, are duplicated for each webservice.
To resolve this I have written the following powershell script to generate .cs files for the webservices which reuse the types.
$svcutil = get-item ((get-item 'Env:\ProgramFiles(x86)').Value + "\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\svcutil.exe")
$csc = "C:\Program Files (x86)\MSBuild\14.0\Bin\csc.exe"
& $svcutil "http://Path/to/WebService/WSTokenService?wsdl" /o:WSTokenService.cs
& $csc /target:library /out:temp.dll WSTokenService.cs
& $svcutil "http://Path/to/WebService/WSAssetService?wsdl" /r:temp.dll /o:WSAssetService.cs
& $csc /target:library /out:temp.dll WSTokenService.cs WSAssetService.cs
& $svcutil "http://Path/to/WebService/WSContactService?wsdl" /r:temp.dll /o:WSContactService.cs
& $csc /target:library /out:temp.dll WSTokenService.cs WSAssetService.cs WSContactService.cs
..
repeat for 8 webservices
This "chains" the webservices together, resusing the shared classes, and seems to work.
Are there any problems with this approach and/or is there a better way to achieve sharing classes between the related webservices?
Edit: please note that these are not webservices developed by us and we do not have access to the code or classes that are used server-side.
Why you did not create one class library project for sharing code between multiple solution? Or you can create project template for all of your microservices. I think, your current method is dirty and unsupported hack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With