Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / March 2007

Tip: Looking for answers? Try searching our database.

Calling a method on a webservice

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bjornms@gmail.com - 29 Mar 2007 10:19 GMT
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.
John Saunders - 29 Mar 2007 18:27 GMT
...

> But...:
> My situation is different.
[quoted text clipped - 18 lines]
> My Question: Does somebody know how to fix those errors? Has it
> something to do with Namespaces? I'm lost here.

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
bjornms@gmail.com - 30 Mar 2007 07:35 GMT
On Mar 29, 7:27 pm, "John Saunders" <john.saunders at trizetto.com>
wrote:
> <bjor...@gmail.com> wrote in message
>
[quoted text clipped - 23 lines]
> > My Question: Does somebody know how to fix those errors? Has it
> > something to do with Namespaces? I'm lost here.

> 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".
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?
Scott Holman - 30 Mar 2007 14:06 GMT
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
John Saunders - 30 Mar 2007 20:43 GMT
> 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
[quoted text clipped - 7 lines]
> same attributes you then need to modify the generated client proxy class
> to use House.Window instead of LogService.Window.

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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.