想要使用C#的asmx的WebMethod來實(shí)現(xiàn)一個(gè)WebService,。想要用戶給服務(wù)器傳遞數(shù)據(jù),finger_print_base64是一個(gè)必須傳遞的固定參數(shù),threshold和mini_matches是兩個(gè)可選參數(shù)。目前已知可以定義MessageName來通過方法重載實(shí)現(xiàn)相同方法名的可選參數(shù)[WebMethod(MessageName="Default")]publicvoidSearchPerson(Stringfinger_print_base64){}[WebMethod(MessageName="AddThreshold")]publicvoidSearchPerson(Stringfinger_print_base64,intthreshold){}[WebMethod(MessageName="AddMinMatches")]publicvoidSearchPerson(Stringfinger_print_base64,intmini_matches){}但是,由于第二個(gè)方法和第三個(gè)方法的參數(shù)類型是相同的,無法實(shí)現(xiàn)重載。想知道是否有其他方法來實(shí)現(xiàn)可選參數(shù)。因?yàn)檫@是一個(gè)功能的接口,不想要改變方法名:SearchPerson,所以不想通用不同的方法名來進(jìn)行區(qū)分。提前謝過各位大佬。
C# HTTP Web Service 方法實(shí)現(xiàn)可選參數(shù)
慕哥6287543
2019-05-25 17:07:17