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.