Question

In ASP.NET, WHY its possible to call a function of a web service with more parameter than the function ask (the superfluous parameters are simply unused)?


I need to do a kind of reverse engineering. I got a web service with the function myFunction(param A, param B)

and I have a web site calling the service with more parameter

MyService.MyFunction(A,B,C);

It's seems working but I don't understand why?

Was it helpful?

Solution

It is not a "web service function". As far as the client is concerned, it's a set of descriptions in a WSDL document. From that description, client code is generated. That client code causes XML (SOAP) to be sent to the service.

It is possible for this to get out of sync. For instance, version 1 of the service may have had 3 parameters on the operation. A client was created for version 1, so it sends 3 parameters.

Version 2 of the service may remove one parameter. If the client is not updated, then it still will send 3 parameters. The service may choose to ignore the extra parameter.

OTHER TIPS

you can also pass a model with the parameters you need, for example, if you are expecting:

firstname, lastname, city

you can make your object as:

public class Person {
    public string firstname { get; set; }
    public string lastname { get; set; }
    public string city { get; set; }
}

and have your method receive a Person object like

public bool SavePerson(Person person) { ... }

later on, you can simply append more properties to the Person object.

So, that might actually be what's going on... let's image that you can pass firstname and lastname, but city is optional.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top