Question

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

It's used in a parameter for a web service defined in project B:

public XmlDocument CreateNewClient(ClientInfo ci, string system)

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

As far as .NET is concerned these are not the same types.

How can I get around this?

Was it helpful?

Solution

My first suggestion would be to use hand-written 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 the Web Services Factory, which has an option to let you reuse existing classes when it generates code (if the classes are appropriate.)

OTHER TIPS

You can use original types by just checking "Reuse types in specified referenced assemblies" and select the assembly containing original types while generating proxies for your web service in the advance settings.

enter image description here

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

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

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

That is the short ugly way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top