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 2005

Tip: Looking for answers? Try searching our database.

Overloading WebMethods

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Raed Sawalha - 16 Mar 2005 14:09 GMT
I have webservice and I need to overload a method but when overloading the
method as following i got error message written below:

[WebMethod(Description="Gets the number of files in the User subfolder that
has that Type name")]
public int MessageCount (string User,string Type )
{
MsgWebService.Utility.UserFolder oUserFolder = new
MsgWebService.Utility.UserFolder(User);       
string[] saFiles = oUserFolder.GetSubfolderFilesName(Type);
return (saFiles == null)? 0 : saFiles.Length  ;
}

[WebMethod(Description="Gets the number of files in the User subfolder that
has that Type name")]
public int MessageCount (string User,string Type,string userId)
{
MsgWebService.Utility.UserFolder oUserFolder = new
MsgWebService.Utility.UserFolder(userId.Substring(0,4),userId);       
string[] saFiles = oUserFolder.GetSubfolderFilesName(Type);
return (saFiles == null)? 0 : saFiles.Length  ;
}

The Error :
*********
Both Int32 MessageCount(System.String, System.String, System.String) and
Int32 MessageCount(System.String, System.String) use the message name
'MessageCount'. Use the MessageName property of the WebMethod custom
attribute to specify unique message names for the methods.

Why I'm getting this error? I dont understand from the message what should I
do?
any help please?
erymuzuan - 16 Mar 2005 15:19 GMT
try to created a diffrent soapaction value for the operation. generally
the SoapAction will be used to bind to the appropriate method.

BTW, a better approach would be to use XML schema to determine the
correct parameter. don't get too fancy with web services as asp.net
might spit out a problematic wsdl and serilizer.

regards
erymuzuan

> I have webservice and I need to overload a method but when overloading the
> method as following i got error message written below:
[quoted text clipped - 29 lines]
> do?
> any help please?
Raed Sawalha - 16 Mar 2005 16:01 GMT
Could you please provide me with more information
(try to created a diffrent soapaction value for the operation) ?

> try to created a diffrent soapaction value for the operation. generally
> the SoapAction will be used to bind to the appropriate method.
[quoted text clipped - 39 lines]
> > do?
> > any help please?
Andy Babiec - 17 Mar 2005 01:01 GMT
A web service is like an http post, where the method name becomes the
unique part of the URL and the message (which in your case is the set
of parameters) is the contents being posted.

your web service will become...
POST /MyWebService.asmx/MessageCount

So you can't have two methods with the same name - thus no overloading.
Nothing to do with Visual Studio, .net, Microsoft.

Why don't you just publish MessageCount (string User,string Type,string
userId)
and let the user ignore the userId parameter - i.e. not pass it in.
Jonathan Eggert - 17 Mar 2005 18:48 GMT
I think you can accomplish this with the MessageName attribute in your web
service method.
Brock Allen - 17 Mar 2005 18:54 GMT
In essence Web Services is a different technology than C#. C# supports overloading
whereas WebServices don't. Just use a different name.

-Brock
DevelopMentor
http://staff.develop.com/ballen

> I have webservice and I need to overload a method but when overloading
> the method as following i got error message written below:
[quoted text clipped - 30 lines]
> do?
> any help please?
Manohar Kamath - 17 Mar 2005 21:21 GMT
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbts
kUsingWebMethodAttribute.asp


While web methods can be overloaded, the SOAP protocoal needs to distinguish
between two methods. Use the MethodName attribute (the above link contains
an example)

Signature

Manohar Kamath
Editor, .netWire
www.dotnetwire.com

> I have webservice and I need to overload a method but when overloading the
> method as following i got error message written below:
[quoted text clipped - 29 lines]
> do?
> any help please?
Jonathan Eggert - 17 Mar 2005 22:26 GMT
Manohar has it right: I meant MethodName not MessageName.

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.