Reputation: 787
i have a web service with signature :
[WebMethod(EnableSession = true)]
public Box FetchBox(string boxId, string p1, string p2, string p3 )
i call this web service by a jquery ajax :
$.ajax({
url: "/WS/Ajaxify.asmx/FetchBox",
data: "{ 'boxId': '" + boxId + "' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8"
});
i want to call FetchBox one time only with p1, later with p2 but not p1 and so on.
in many situations i need to call FetchBox method with any of p1 or p2 or p3 or ... parameter. i dont like to send all parameters because the system is plugin based and plugins do not know about others parameters.
optional parameter in c#4 does not working for a web service.
also params string[] parameters is not suitable here because i need to know the parameter name.
Upvotes: 1
Views: 3198
Reputation: 161831
You cannot send optional parameters to a SOAP web service. The SOAP protocol has no concept of optional parameters.
Also, you should not be using ASMX services at all. That's a legacy technology that shouldn't be used for new development. WCF should be used instead.
Upvotes: 3