473,803 Members | 2,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

overloading default constructor in web services

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?
Nov 23 '05 #1
4 12663
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
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?

Nov 23 '05 #2
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(wit h
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.

"Dilip Krishnan" wrote:
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
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?


Nov 23 '05 #3
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,

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(wit h
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.

"Dilip Krishnan" wrote:
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
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?

Nov 23 '05 #4
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.
"Dilip Krishnan" wrote:
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,

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(wit h
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.

"Dilip Krishnan" wrote:
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
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?


Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
4771
by: Marcelo Pinto | last post by:
Hi all, In practice, what is the diference between a default constructor and an explicit default constructor? class Ai { public: Ai() {} };
18
3005
by: Matt | last post by:
I try to compare the default constructor in Java and C++. In C++, a default constructor has one of the two meansings 1) a constructor has ZERO parameter Student() { //etc... } 2) a constructor that all parameters have default values
19
6570
by: Andrew J. Marshall | last post by:
I want to create a class that must receive a parameter when instantiated. In other words, I do not want it to have a "Public Sub New()". 1) Does VB.NET create a default public constructor if I do not declare one? 2) I've read that I can have a "Private Sub New()" which should take care of my needs. Comments? Thanks, Andrew
4
6505
by: Rich | last post by:
Public Class clsTest Public Sub New() Console.WriteLine("inside default constructor") End Sub Public Sub clsTest(ByVal s As String) Console.WriteLine(s) End Sub Public Sub clsTest(ByVal s As String, ByVal t As String)
12
2160
by: Dave A | last post by:
I have a class that does not have a default constructor. The nature of the class inherently excludes it from having one and to put one in will blatantly misrepresent the object that it is modelling. So having said that, how do I get it to go through SOAP when SOAP requires that the class has a default constructor? In ASP.NET 2 the error message is "<class> cannot be serialized because it does not have a parametless constructor" (please...
7
4218
by: =?Utf-8?B?TWlrZQ==?= | last post by:
I'm building a C# application that uses web services. I have a class with a default constructor, an overloaded constructor, and some web methods. When VS creates the asmx file, it doesn't include the overloaded constructor. Plus it doesn't initialize the private objects in the class. Is there a way to tell VS to include the constructors and initialize the member objects? tia
74
16040
by: Zytan | last post by:
I have a struct constructor to initialize all of my private (or public readonly) fields. There still exists the default constructor that sets them all to zero. Is there a way to remove the creation of this implicit default constructor, to force the creation of a struct via my constructor only? Zytan
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9565
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10550
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10317
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.