i have two methods named as
[OperationContract]
UserAccount GetUser(Int32 id);
[OperationContract]
UserAccount GetUser(string username, string password);
when i try to build them, they said you can not have same name methods in service ? Is it.
i have two methods named as
[OperationContract]
UserAccount GetUser(Int32 id);
[OperationContract]
UserAccount GetUser(string username, string password);
when i try to build them, they said you can not have same name methods in service ? Is it.
This is a limitation of WSDL. It does not support the same overloading concepts as C#/.NET, so that method names on services have to be unique. You have two option to resolve your problem.
First one is to use diffrent names for your methods. The other one is to set the Name property on one of your OperationContracts like so
[OperationContract(Name="GetUserById")]
UserAccount GetUser(Int32 id);
[OperationContract]
UserAccount GetUser(string username, string password);
WSDL does not support the same overloading concepts of c#. You can use Name in your OperationContract to specify your methods
[OperationContract(Name="GetUserInt")]
UserAccount GetUser(Int32 id);
[OperationContract(Name="GetUserString")]
UserAccount GetUser(string username, string password);
Try this:
- [OperationContract(Name= "GetUserWithID")]
UserAccount GetUser(Int32 id);
- [OperationContract(Name= "GetUserWithUserName")]
UserAccount GetUser(string username, string password);
This is the drawback of WCF. Reason behind this is that when we relies the service for client then there should be no duplication, otherwise client will confuse which method is doing what? So here are the options to resolve the problem. By using the different name attribute of Operation Contract.
[OperationContract(Name="GetUserByID")]
UserAccount GetUser(Int32 id);
[OperationContract(Name="GetUserByUName_Password")]
UserAccount GetUser(string username, string password);