Question

I have a C# project which has many web references to a third party product. All of these web service calls use a 'user context' class. So each web service accepts the exact same XML snippet.

Currently I have to keep many of these 'user context' objects around as I hit all the different web service calls. The generated 'user context' class is the exact same but just put in different .NET namespaces (the XML namespace is the same).

I would like to be able to have only one of these instances passed around. How could I do that?

I am using Visual Studio 2010 and using the generated class by adding a WebReference. I'm not opposed to using some other framework or mechanism. I had even thought of rolling my own code, but there are many WebServices (each with many web methods) that I will need to use.

Update: I originally added these by adding a Web Reference, I will now be adding them as a Service Reference. The web services themselves are exposed through InterSystems Caché and I haven't looked into how well they conform to WS-I.

Was it helpful?

Solution

Not sure about VS 2010, but in 2008 there was an option "reuse types in referenced assemblies" in the service reference adding wizard which does just what you need. In order to have the same type in all web references create an assembly, put those type definition there, reference it from your project and then add web references you need.

OTHER TIPS

I resolved a problem like this by using only one class and converting the object with XML serialization/deserialization. But still it's not the perfect solution.

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