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?
尝试使用操作名称,这应该在Java中正常工作:
@WebMethod(operationName="newName")
据我所知,有一些SOAP技巧可以实现重载,但不是应该如何 - 不要使用重载来实现Web服务。
这可以通过为以上两个函数提供如下的不同(唯一)MessageName属性来完成
[WebMethod (MessageName="ABC")]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.