I am using Java 6 and spring-ws to create a very simple web service which receives 2 parameters in the form of a BusquedaRequest Jaxb object and returns the same object.
The object has been created with xjc compiler and I am using Jaxb2Marshaller as the mashaller and GenericMarshallingMethodEndpointAdapter to convert to incoming xml and out going. I had this working when extending the AbstractMarshallingPayloadEndpoint class but when I switch to using the Endpoint and payload annotations it always fails.
The web service starts up fine but when hitting it with a client I recieve this exception.
java.lang.IllegalStateException: No adapter for endpoint [public package.busqueda.ws.BusquedaRequest package.busqueda.ws.BusquedaEndpoint.getResultas(package.busqueda.ws.BusquedaRequest)]: Does your endpoint implement a supported interface like MessageHandler or PayloadEndpoint?
at org.springframework.ws.server.MessageDispatcher.getEndpointAdapter(MessageDispatcher.java:286)
at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:227)
at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:170)
at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88)
at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:57)
at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:230)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
I have seen response to this question which suggest to compile objects using the xjc compiler which I have done. Also there has been suggestions that the Adaptor hasn't been defined in the spring-ws-servlet.xml, which I have also done. See the spring-ws-servlet.xml defined below:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLS开发者_如何学JAVAchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="busquedaEndpoint" class="package.BusquedaEndpoint" />
<bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
<constructor-arg ref="marshaller"/>
</bean>
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>package.BusquedaRequest</value>
</list>
</property>
</bean>
<bean id="busqueda"
class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
<property name="schema" ref="schema" />
<property name="portTypeName" value="Busqueda" />
<property name="locationUri" value="/BusquedaService/" />
</bean>
<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
<property name="xsd" value="/WEB-INF/busqueda.xsd" />
</bean>
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping"/>
</beans>
The class endpoint is as follows:
package package.busqueda.ws;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
@Endpoint
public class BusquedaEndpoint {
@PayloadRoot(localPart = "BusquedaRequest", namespace = "http://busqueda/schemas")
public BusquedaRequest getResultas( BusquedaRequest aRequest ) {
return aRequest;
}
}
The xsd I generated the BusqeudaRequest object is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="qualified"
xmlns="http://busqueda/schemas"
targetNamespace="http://busqueda/schemas">
<xs:element name="BusquedaRequest">
<xs:complexType>
<xs:all>
<xs:element name="Consulta" type="xs:string" />
<xs:element name="Permisos" type="xs:string" />
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
Anyone got any thoughts which extend the suggestions I have already implemented?
When faced with the same problem, I found that adding @RequestPayload and @ResponsePayload annotations to the parameters of the method in the EndPoint implementation would solve the issue.
@whatsthebeef Maybe it's offtopic, or late, but what I see where the problem is, the way you use Marshaller from my point of view stinks.
Why do you use classesToBeBound? If you use XJC & JAXB generating process you really should point 'just' to the package i.e.
<bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPaths">
<list>
<value>my.package.where.the.jaxb-generated.stub-objects.reside</value>
</list>
</property>
</bean>
2nd thing is, how should spring context know about your marshaller? I miss using the appropriate Marshaller.
<bean id="endpointAdapter" class="org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter">
<constructor-arg ref="jaxb2Marshaller"/>
</bean>
That's the way i did it with the current spring-ws package. Btw the stacktrace tells you that the problem is with the *EndpointAdapter. Please let me know if it helped you.
精彩评论