Can we implement method overloading in web service class?

后端 未结 2 2141
遥遥无期
遥遥无期 2020-12-06 12:46

I would like to implement method overloading in the Java web service class as follows:

public String myMethod(User user)
{
    // My code
} 

public String m         


        
2条回答
  •  执念已碎
    2020-12-06 13:38

    Overloading the web service methods is not difficult. With Axis 1.4 at least it is fairly simple. If there are two overloaded methods in the service like below:

    public String myMethod(String firstName, String lastName) throws RemoteException
    public String myMethod(String name) throws RemoteException
    

    Then a request like this:

    http://localhost:8080/services/testService?method=myMethod&name= 
    

    will invoke the second method.

    And a request like this one:

    http://localhost:8080//services/testService?method=myMethod&firstName=&lastName=
    

    will invoke the first method.

    The resolution is done by Axis.

提交回复
热议问题