views:

36

answers:

2

Suppose I have the following methods declared in my web service:

@WebMethod()
public Long addNewApplication(String applicationName) throws ServiceManagerException {
    // implementation
}

@WebMethod()
public Long addNewApplication(String applicationName, ApplicationState status) throws ServiceManagerException {
    // implementation
}

The problem is that above doesn't work, I get the following exception:

org.springframework.remoting.jaxws.JaxWsSoapFaultException: Cannot find dispatch method for Request=[SOAPAction="",Payload={http://example.org/applicationManager}addNewApplication]; nested exception is javax.xml.ws.soap.SOAPFaultException: Cannot find dispatch method for Request=[SOAPAction="",Payload={http://example.org/applicationManager}addNewApplication]
at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.doInvoke(JaxWsPortClientInterceptor.java:503)
at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.invoke(JaxWsPortClientInterceptor.java:487)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy123.addNewApplication(Unknown Source)

If I rename methods so they will have different names, everything works. Is it possible to have overloaded methods in Web Service? If yes, then how?

+1  A: 

As far as I recall there were some SOAP tricks that enables something like overloading, but it's not how it should be - don't use overloading for web services.

Bozho
Heh... Currently i forced to rename the methods to remove overloading. But it is not very elegant solution.
uthark
@uthark: In the context of WSDL, which doesn't support overloading, one could argue it actually is the most elegant solution.
Fabian Steeg
@Fabian Yep, actually before posting question I've removed overloading. But I wanted to know if it is possible to overload.
uthark
A: 

This can be done by providing a different (unique) MessageName Property as below for both of the above functions

[WebMethod (MessageName="ABC")]
Nishant
I'm using Java, not .net.
uthark