Converting web service class

Posts   
 
    
mattsmith321 avatar
Posts: 146
Joined: 04-Oct-2004
# Posted on: 26-Apr-2005 23:06:28   

Completely unrelated to LLBL but I know someone out there can provide some input:

We've got a Web Service layer that we are calling that returns custom objects which are defined in the web service project. It took me a little while to get used to the syntax of casting through the web service (WidgetService.CustomWidget widget = service.GetWidgets()) but everything works fine so far.

However, I now want to do a little more with my custom objects on the process side. I wanted to create a Formatter class which would have a series of overloads for my different objects to correctly build a formatted string for presentation. Since it is static calls and that class has no real need to "know" about the web service objects, I thought I would create my custom objects in an assembly that is common to both web service and process layer. Then I could reference my objects from my common namespace. Wrong! I now get a message that I can't convert from WebService.CustomWidget to Common.CustomWidget (even with casting).

Any recommendation on how to handle this? Am I stuck with having my Formatter class having a reference to my WebServices class just so it knows what the objects are?

Thanks!

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 27-Apr-2005 03:03:16   

Define your objects via an interface. put the interface in a shared assembly. have both the web services assembly and the business layer reference the shared assembly and the interfaces. when you create your web proxy, manually edit the proxy to case the objects returned as the interface and you should be all set.

mattsmith321 avatar
Posts: 146
Joined: 04-Oct-2004
# Posted on: 27-Apr-2005 05:57:10   

Devildog74 wrote:

Define your objects via an interface. put the interface in a shared assembly. have both the web services assembly and the business layer reference the shared assembly and the interfaces. when you create your web proxy, manually edit the proxy to case the objects returned as the interface and you should be all set.

Thanks for the guidance. This actually helped refine my google queries and I came up with the following articles which provide the necessary detail to do what I want to do:

Thanks again!