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

dotnet web services

group:

abstract class overriding?


abstract class overriding? drb
3/24/2005 12:41:08 PM
dotnet web services:
Hi,

I'm hoping this is a stupid question, so I apologize in advance.

After creating WSDL files from scratch for a new web service, I used the
WSDL.exe tool to generate C# stubs for both the web service server methods
and the client proxy methods. The tool created the server methods as
abstract member methods of an abstract class that derived from
System.Web.Services.WebService. I *thought* what I needed to do was create
another class that derived from this class, so I did, and
implemented/overrode the methods in the derived class. And everything built
in VS.NET successfully.

I then created a test client console app using the client proxy methods, and
tried to call the web service. But the call failed with the error:

An unhandled exception of type 'System.Web.Services.Protocols.SoapException'
occurred in system.web.services.dll
Additional information: Server was unable to process request. --> Cannot
create an abstract class.

From the error it looks like the web service was found OK, but something in
the web service (or the service itself?) couldn't be instantiated? If I run
the service in the VS.NET debugger I get an IE page displaying the service
methods/messages successfully, so I thought everything was being instantiated
properly. I tried explicitly adding all the various web service attributes
that the WSDL.exe tool placed on the abstract class definition/methods to the
derived class as well, but that didn't seem to work.

I *think* I'm missing something obvious, but don't know where to look, so I
came to the land of experts. If I can provide any more information let me
Re: abstract class overriding? Manohar Kamath
3/24/2005 3:18:45 PM
I guess you are using the /server option when you are creating your proxy
class. It will create an abstract class. If you exclude it, you will get a
concrete class.

wsdl http://myhost/mywebservice.asmx?wsdl


--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com


[quoted text, click to view]

Re: abstract class overriding? drb
3/25/2005 4:47:03 AM
Hi Manohar,

Thanks for your reply. Yes, I did use the "/server" switch because I
thought that's what I was supposed to do to generate the server stubs. When
I saw that the tool generated an abstract class and methods, and saw the
comments in the file warning not to modify the file, it seemed to make sense.
I would override the class/methods in a separate file in the VS.NET project,
and then "somehow" .NET would hook my method overrides into the service at
runtime. When it built successfully I thought I was on the right path.

So there's really no way to use/override the abstract class generated for
the server side when using the "/server" switch? I can't believe the tool
would produce something unusable. Is the abstract class just supposed to be
some sort of "guide"? This problem seems so basic that I thought surely
someone must have hit this problem (and hopefully solved it) before.

Anyway, thanks again - I do appreciate the help so far.

Dave

[quoted text, click to view]
Re: abstract class overriding? drb
3/25/2005 7:27:01 AM
I finally found this. The posted text is about 3/4 of the way through the
article.

---------------------------------------

http://msdn.microsoft.com/msdnmag/issues/02/09/XMLFiles/

"When you derive your new class, make sure that you copy all of the
customization attributes from the generated class to the derived class
(including those on each method). The customization attributes are not
inherited by design. Overlooking this step will break the WSDL contract that
you started with. Then to finish off the implementation, you simply need to
create an .asmx file with a single ASP.NET directive referencing your new
class, like so:

<%@ WebService language="C#" class="GeometryServiceImpl" %>

---------------------------------------

This was exactly what I had been hoping to find. I tried it and it worked.
Hope this helps someone else who's trying to start from scratch with WSDL and
Re: abstract class overriding? Manohar Kamath
3/25/2005 11:51:24 AM
Dave,

From my previous post -- do not use the /server option when using wsdl. The
generated class will be a concrete class that you could use as-is.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com


[quoted text, click to view]

AddThis Social Bookmark Button