How to avoid web method parameters using proxy classes?

I have a serializable POCO called DataUnification.ClientData.ClientInfo in a .NET.NET A library project.

It is used in the parameter for the web service defined in project B :

 public XmlDocument CreateNewClient(ClientInfo ci, string system) 

Now I want to call this web method from project C and use the original type DataUnification.ClientData.ClientInfo in the parameter. However, due to the generated proxy class, it has now become a different type: WebServices.ClientDataUnification.DataUnificationWebService.ClientInfo .

As for .NET, these are not the same types.

How can I get around this?

+4
source share
4 answers

My first suggestion would be to use handwritten proxies instead of generated proxies, so you have full control over which types are used.

My second suggestion would be to use a tool like Factory Web Services, which can allow you to reuse existing classes when generating code (if the classes are suitable).

0
source

You can use the original types by simply checking the "Reuse Types in Specified Reference Assemblies" and select the assembly containing the original types when creating the proxy for your web service in the presets.

enter image description here

+2
source

You can use automapper http://automapper.codeplex.com/ to create a new DataUnification.ClientData.ClientInfo from an instance of WebServices.ClientDataUnification.DataUnificationWebService.ClientInfo.

0
source

You can β€œshow all files” and copy the contents of the generated reference.cs into a new file, and then delete the generated proxy server and all its dependent files.

Now, in your new reference.cs, delete the generated dto classes and update all the links.

This is a short ugly way.

0
source

Source: https://habr.com/ru/post/1309612/


All Articles