Divide Enumeration Between ASMX Web Services

I have a web service project with several web services. Two of these web services share an enumeration that is defined in the BL class, for example:

public class HumanResourcesService { public SomeLibrary.Employee GetEmployee(int employeeCode) { var employee = new SomeLibrary.Employee(); employee.Type= SomeLibrary.EmployeeType.SomeType; return employee ; } } public class BankService { public bool ProcessPayment(int employeeCode, EmployeeType employeeType) { bool processed = false; // Boring code return processed; } } 

This is just an example.

Both web services referenced in the web project generate different EmployeeType enum proxies, so I need to explicitly specify the ProcessPayment method in BankService :

 public void SomeMethod(int employeeCode) { var hrService = new HumanResourcesService(); var employee = hrService.GetEmployee(employeeCode); var bankService = new BankService(); bankService.ProcessPayment(employee.Code, (MyProject.BankService.EmployeeType) employee.Type); } 

I understand that .NET must do this in order to create WSDL, but can I somehow get both services to reference the same enum to proxy classes without breaking anything?

+7
source share
2 answers

You can use the sharetypes parameter of the wsdl.exe file. See http://msdn.microsoft.com/en-us/library/7h3ystb6.aspx for more details.

+3
source

If you set the same enumeration, proxies will work fine:

 public class BankService { public bool ProcessPayment(int employeeCode, MyProject.BankService.EmployeeType employeeType) { bool processed = false; // Boring code return processed; } } public void SomeMethod(int employeeCode) { var hrService = new HumanResourcesService(); var employee = hrService.GetEmployee(employeeCode); var bankService = new BankService(); bankService.ProcessPayment(employee.Code, employee.Type); } 
0
source

All Articles