假设我在我的Web服务中声明了以下方法:
@H_502_2@@WebMethod()
public Long addNewApplication(String applicationName) throws ServiceManagerException {
// implementation
}
@WebMethod()
public Long addNewApplication(String applicationName,ApplicationState status) throws ServiceManagerException {
// implementation
}
问题是上面不起作用,我得到以下异常:
@H_502_2@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)如果我重命名方法以便它们具有不同的名称,那么一切都有效.是否可以在Web Service中使用重载方法?如果是,那怎么样?
解决方法
据我所知,有一些SOAP技巧可以实现重载,但不是应该如何 – 不要使用重载来进行Web服务.