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 / February 2005

Tip: Looking for answers? Try searching our database.

overloading default constructor in web services

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
indigator - 28 Jan 2005 17:19 GMT
I have an ASP.Net web service class, DataLayer.asmx.cs. I have two
constructors for the DataLayer class. One is the default parameter-less one
and the second one accepts a string argument. When I am trying to consume
this web service from another asp.net application, only the default
parameter-less constructor shows up. And if i try creating an instance of the
second constructor, it gives me a compiler error saying that No overload of
DataLayer() takes 1 argument. I checked the proxy class Reference.cs in my
client application and I couldn't find the overloaded constructor. Is it that
web services do not support overloaded constructors? Am i missing something?
Dilip Krishnan - 28 Jan 2005 18:35 GMT
Hello indigator,
   What you see in the Reference.cs is a proxy and not the service itself.
The proxy itself has no knowledge of the implementation of the service. It
just knows any methods that are exposed by the service based on whats defined
on the wsdl. Possibly what you need in the constructor could be passed as
a parameter to the webservice.. or configured in the web.config that the
service can lookup

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

> I have an ASP.Net web service class, DataLayer.asmx.cs. I have two
> constructors for the DataLayer class. One is the default
[quoted text clipped - 7 lines]
> web services do not support overloaded constructors? Am i missing
> something?
indigator - 31 Jan 2005 15:35 GMT
Hey Dilip,

Thanks for the reply. So does this mean Webservices do not support
Overloaded constructors? I am trying to pass some information as a parameter
to the constructor, so that the webservice can initialize the fields once the
instance is created. To be more precise, I am trying to create a datalayer
using webservices. So i need to pass the connection string as a parameter to
the webservice class. Currently, when i try to create an instance of the
webservice class from an asp.net application, it shows only the default
parameter-less constructor, even though I have specified 2 constructors. If I
ignore this and try to create an instance using the 2nd constructor(with
parameter), it gives me a compilation error saying that "No overload for
method 'MethodName' takes '1' arguments.

I cannot specify this in the web.config file, since everytime, they need to
connect to a new database, the web.config has to be changed. So does this
mean I should have another Web method which will perform the same function
and not use the constructor? I hope I am clear.

Thanks.

> Hello indigator,
>     What you see in the Reference.cs is a proxy and not the service itself.
[quoted text clipped - 22 lines]
> > web services do not support overloaded constructors? Am i missing
> > something?
Dilip Krishnan - 01 Feb 2005 06:08 GMT
Hello indigator,
  Why not just pass in an (encrypted ??) connection string as a parameter
to the web method?

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

> Hey Dilip,
>
[quoted text clipped - 47 lines]
>>> Is it that web services do not support overloaded constructors? Am i
>>> missing something?
indigator - 01 Feb 2005 15:19 GMT
Hey Dilip,

I guess I will do that. I just preferred passing it as a parameter to the
constructor since I didn't want client applications to call one extra method
to set the connection string. :)

Thanks for your help.

> Hello indigator,
>    Why not just pass in an (encrypted ??) connection string as a parameter
[quoted text clipped - 58 lines]
> >>> Is it that web services do not support overloaded constructors? Am i
> >>> missing something?

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.