忽略 asmx Web 服务中的参数



我创建了以下 Web 服务

>         [WebMethod(EnableSession = true)]
>   
>         public Transaction<Employee> GetEmployee(string Fname, string Lname, int eid)
>         {
>             
>             return _service.GetEmployee(Fname, Lname, apartmentTypeId, eid);
>         }

我想使最后一个参数可选。目前,我不是 提交开斋节,它会给出错误。我怎样才能做最后 参数在此服务中可选?

你不能。Web 方法不支持可选参数。当您为 Web 方法生成 proxi 时,您可以获取特定的签名,根据该签名,您的客户端和服务器将交换消息。但它不能传递可选参数。您可以在服务器端使用默认参数,但不能使用可选参数。

具有可选参数的 Web 服务方法

最新更新