all groups > dotnet web services > march 2007 >
You're in the

dotnet web services

group:

Calling a method on a webservice


Calling a method on a webservice bjornms NO[at]SPAM gmail.com
3/29/2007 2:19:48 AM
dotnet web services: Hi,

I have a question related to webservices on the Microsoft platform.

Context:
I have two projects. One is called LogService. The other is called
client. The LogService is a C# webservice developed on VS.NET 2005.
The client is a seperate project developed in VS.NET 2005 which uses
(in the project using a webreference) the webservice LogService.


Introduction:
I'm trying to call the method Log with an argument Window on a
webservice called LogService. This Window Class is defined under the
namespace House in the webservice project. So if i want to instantiate
a Window in the LogService, i do the following: "House.Window window =
new House.Window();".

If i want to call the Log method on the client project which has a web
reference to the LogService named LogService i do the following:
LogService.LogService logService = new LogService.LogService();
LogService.window window = new LogService.Window();
logService.Log(window);

But...:
My situation is different.
For some reason ( i'm not going to explain it here ), i do not use the
Window definition from LogService. Instead, on the client project i
also have a namespace House with a class Window, which is exactly
identical to that on the webservice LogService. To call the method Log
i do the following:
LogService.LogService logService = new LogService.LogService();
House.Window window = new House.Window();
logService.Log(window);

But... then i get some errors which i can not get rid of.
The errors i get:
1) The best overloaded method match for
'LogService.LogService.Log(LogService.Window)' has some invalid
arguments
2) Argument '1': cannot convert from House.Window to LogService.Window

And i also can't cast between the two classes.

My Question: Does somebody know how to fix those errors? Has it
something to do with Namespaces? I'm lost here.
Re: Calling a method on a webservice John Saunders
3/29/2007 1:27:51 PM
[quoted text, click to view]

The two classes are not related in any way that matters to C#. Of course
you're going to get errors. You'd get the same result if you passed an
"int".

John

Re: Calling a method on a webservice bjornms NO[at]SPAM gmail.com
3/29/2007 11:35:12 PM
On Mar 29, 7:27 pm, "John Saunders" <john.saunders at trizetto.com>
[quoted text, click to view]
Ok, they are not related for C#. For me they are. Actually, for me
they are identical. So is there a way to typecast between the both? Or
do i have to create a copy constructor? Or is there another solution
to this problem?

Re: Calling a method on a webservice Scott Holman
3/30/2007 9:06:56 AM
As john pointed out the classes are not the same. If your using WCF it is
fairly easy to modify the generated proxy code and replace class
implementations. If you are using pre .net3.0 web services you may be able
to do something similar.

You need to modify the generated client proxy class and replace the
generated LogService.Window class with House.Window. You need to make sure
that your implementation of House.Window is decorated with the same
attributes as the class in the generated client proxy. After applying the
same attributes you then need to modify the generated client proxy class to
use House.Window instead of LogService.Window.


Scott

Re: Calling a method on a webservice John Saunders
3/30/2007 3:43:05 PM
[quoted text, click to view]

To my mind, it would be safer not to edit the proxy class, as it is a
generated class. Instead, yes, create a copy constructor.

John

AddThis Social Bookmark Button