Search code examples
web-services.net-3.5c#-3.0parametersreference-type

How do I pass reference types between webservices?


I'm having a bit of difficulty passing a reference type between webservices.

My set up is as follows.

I have a console application that references two web-services:

  1. WebServiceOne
  2. WebServiceTwo

WebServiceOne declares the details of a class I am using in my console application...let's call it MyClass.

My console application calls WebServiceOne to retrieve a list of MyClass.

It then sends each MyClass off to WebServiceTwo for processing.

Within in the project that holds WebServiceTwo, there is a reference to WebServiceOne so that I can have the declaration of MyClass.

The trouble I'm having is that, when I compile, it can't seem to determine that the MyClass passed from the console application is the same as the MyClass declared in WebServiceOne referenced in WebServiceTwo.

I basically get an error saying Console.WebServiceOne.MyClass is not the same as MyProject.WebServiceOne.MyClass.

Does anyone know if doing this is possible? Perhaps I'm referencing WebServiceOne incorrectly? Any idea what I might be doing wrong?

My only other option is to pass each of the properties of the reference type directly to WebServiceTwo as value types...but I'd like to avoid that since I'd end up passing 10-15 parameters.

Any help would be appreciated!


Solution

  • I had a chat with one of the more senior guys at my work and they proposed the following solution that has worked out well for me.

    The solution was to use a Data Transfer Object and remove the reference to WebServiceOne in WebServiceTwo.

    Basically, in WebServiceTwo I defined a representation of all the value type fields needed as BenefitDTO. This effectively allows me to package up all the fields into one object so I don't have to pass each of them as parameters in a method.

    So for the moment, that seems to be the best solution...since it works and achieves my goal.

    It's likely that I didn't explain my question very well...which explains why no one was able to help...

    But thanks anyway! :-)