views:

112

answers:

2

I have a web service project that has 2 asmx files. Let’s call them internal.asmx & external.asmx In practice, these have different clients:

Externally a client will call externalWS.PersistOrder(Order order ) and internally, we process the order internalWS ProcessOrder(Order order). Therefore the Order class is a shared dependency across these webservices.

I am writing a test application that calls different webmethods on both of these webservices.

I am having problems because the web services use the same classe. In order to use both webmethods, I am adding 2 webreferences to my test project. However, there are 2 copies of the dependant classes, with different namespaces. As a short term fix I am editing the classes that VS creates.

There has to be a better way! Thanks in advance for your help.

A: 

AutoMapper: the Object-Object Mapper

http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/01/22/automapper-the-object-object-mapper.aspx

Alex Reitbort
This mapper has some interesting applications..
brian chandley
+1  A: 

I am not sure how (and if) you can modify the behavior of the VS web reference wizard.

You could, however, use wsdl.exe or svcutil.exe (depending on whether you want System.Web or WCF-style client proxy to your services) from the command line and specify the appropriate option for shared types.

For wsdl.exe the command line option you want is /sharetypes, though I haven't touched it in years, so I don't remember the exact usage details.

For svcutil.exe the command line option you want is /reference:. This you to have the shared class in an assembly you can reference. If the only definition of the shared class you can get to is in the WSDL of the two services, you might need to use svcutil.exe to generate client proxy, trim it down to contain the shared class only and build a reference assembly from it for the actual client proxies for the two services.

The drawback of this approach is that if the WSDL for one of the services change, you need to run the tool again. This can be mitigated by adding a custom task tot he BeforeBuild target in your project that runs the tool always against both services.

Franci Penov
Thanks Franci. So VS.NET does no support this, but these are workarounds using the underlaying tools VS.NET uses. Glad to hear I was not missing an obvious approach to this problem.Brian
brian chandley
VS.NET does not support this with the old ASMX services, but does with WCF, which should be used for any new development.
John Saunders