我目前的任务是为各种服务器重新设计我们的webservice层。
在 Websphere (8.5.5.9 - 使用axis2 afaik)或 Tomcat (7使用com.sun.xml.ws:jaxws-rt)上,服务不会如果@WebService
班级的@WebMethod
与另一个班级同名,则工作 - 在 JBoss (EAP 6.2)上工作正常。
有没有人知道此问题的解决方法/原因(最好是不涉及重命名方法的那个)?
// example class one
@WebService(name = "ServiceOne", targetNamespace = "http://serviceone.namespace/", serviceName = "ServiceOne")
public class ServiceOne {
@WebMethod
public ServiceOneResponse echo(final ServiceOneRequest request) {
String echo = request.getPayload();
ServiceOneResponse resp = new ServiceOneResponse();
resp.setPayload("ServiceOne echo: " + echo);
return resp;
}
}
// example class two
@WebService(name = "ServiceTwo", targetNamespace = "http://ServiceTwo.namespace/", serviceName = "ServiceTwo")
public class ServiceTwo {
@WebMethod
public ServiceTwoResponse echo(final ServiceTwoRequest request) {
String echo = request.getPayload();
ServiceTwoResponse resp = new ServiceTwoResponse();
resp.setPayload("ServiceTwo echo: " + echo);
return resp;
}
}
// request class one
@XmlRootElement(namespace = "http://serviceone.request/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "http://serviceone.request/")
public class ServiceOneRequest {
String payload;
public String getPayload() {
return payload;
}
public void setPayload(final String payload) {
this.payload = payload;
}
}
// request class two
@XmlRootElement(namespace = "http://servicetwo.request/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "http://servicetwo.request/")
public class ServiceTwoRequest {
String payload;
public String getPayload() {
return payload;
}
public void setPayload(final String payload) {
this.payload = payload;
}
}
在 Websphere 上,服务是自动检测的,在 Tomcat 上,它们将使用 sun-jaxws.xml 绑定到单独的端点。< / p>
我看到的行为是:
太阳jaxws.xml :
<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
version="2.0">
<endpoint name="ServiceOne"
implementation="com.dsw.services.soap.ServiceOne"
url-pattern="/soap/one" />
<endpoint name="ServiceTwo"
implementation="com.dsw.services.soap.ServiceTwo"
url-pattern="/soap/two"/>
</endpoints>
Soap-Fault(使用SoapUI):
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Server</faultcode>
<faultstring>argument type mismatch</faultstring>
</S:Fault>
</S:Body>
</S:Envelope>
...和匹配的Tomcat stacktrace:
Apr 13, 2016 10:30:47 AM com.sun.xml.ws.server.sei.TieHandler createResponse
SEVERE: argument type mismatch
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.xml.ws.api.server.MethodUtil.invoke(MethodUtil.java:83)
at com.sun.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:250)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:149)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:88)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
at com.sun.xml.ws.api.pipe.Fiber.run(Fiber.java:813)
at com.sun.xml.ws.api.pipe.Fiber.start(Fiber.java:420)
at com.sun.xml.ws.server.WSEndpointImpl.processAsync(WSEndpointImpl.java:368)
at com.sun.xml.ws.server.WSEndpointImpl.process(WSEndpointImpl.java:398)
at com.sun.xml.ws.transport.http.HttpAdapter.invokeAsync(HttpAdapter.java:734)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.invokeAsync(ServletAdapter.java:212)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:161)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:197)
at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:81)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)