Spring-WSとJAXBを使用してサンプルのSOAP Webサービスを作成しようとしていますが、醜い例外があります。AbstractMethodEndpointMappingのAbstractMethodEndpointMappingのSpringメソッドをSpring-WSとJAXBで実装する
私は次のように構成されたサーバーとしての桟橋を使用しています:http://localhost:8080/loginService/loginService.wsdl私はWSDLを見ることができます:私はアドレスを持つブラウザからWSDLにアクセスすると
。興味深いのは、もし私がhttp://localhost:8080/loginService/asdasdasd/loginService.wsdlのようなアドレスを書くと、それも機能するということです。
しかし、私はあるsoapUIで要求を作っているとき、私は、スタックトレースを取得する:ここで
2012-01-05 13:07:30.010::WARN: /loginService/
java.lang.AbstractMethodError: org.springframework.ws.server.endpoint.mapping.AbstractMethodEndpointMapping.getLookupKeyForMessage(Lorg/springframework/ws/context/MessageContext;)Ljava/lang/Object;
at org.springframework.ws.server.endpoint.mapping.AbstractMethodEndpointMapping.getEndpointInternal(AbstractMethodEndpointMapping.java:55)
at org.springframework.ws.server.endpoint.mapping.AbstractEndpointMapping.getEndpoint(AbstractEndpointMapping.java:117)
at org.springframework.ws.server.MessageDispatcher.getEndpoint(MessageDispatcher.java:256)
at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:210)
at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:172)
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:222)
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:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:722)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:404)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
はLoginEndpointです:
public class LoginEndpoint {
private static final String NAMESPACE = "http://www.asd.eu/knowlEDGE/loginService";
private static final String LOGIN_REQUEST = "login-request";
@PayloadRoot(localPart = LOGIN_REQUEST, namespace = NAMESPACE)
public LoginResponse getUser(LoginRequest request) {
LoginResponse response = new LoginResponse();
response.setPassword("my_secret_password");
return response;
}
}
これはの.xsdファイルです:
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.asd.eu/knowlEDGE"
targetNamespace="http://www.asd.eu/knowlEDGE/loginService"
elementFormDefault="qualified">
<!-- xmlns - Address of our schema -->
<!-- targetNamespace - Address of our service. Adding .wsdl at the end gives the wsdl. It has to be the same with the namespace from PayloadRoot -->
<!-- elementFormDefault="qualified" - all the local defined elements are associated just to this namespace -->
<!-- Login Request Definition -->
<xsd:element name="login-request"> <!-- It has to be the same with the localpart from PayloadRoot -->
<xsd:complexType>
<xsd:attribute name="username" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<!-- Login Response Definition -->
<xsd:element name="login-response">
<xsd:complexType>
<xsd:attribute name="password" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:schema>
これはspring-ws-context.xmlです。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config/>
<context:component-scan base-package="eu.asd.knowlEDGE.service.endpoint" />
<!-- MARSHALLER DEFINITION -->
<!-- the package where the sources will be generated, given the namespace -->
<bean id="knowledge.marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"
p:contextPath="eu.asd.knowledge.loginservice">
</bean>
<!-- ENABLE OXM MARSHALLING -->
<bean class="org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter">
<description>Enables the MessageDispatchServlet to invoke methods requiring OXM marshalling.</description>
<property name="marshaller" ref="knowledge.marshaller" />
<property name="unmarshaller" ref="knowledge.marshaller" />
</bean>
<!-- ENDPOINT DEFINITION -->
<bean id="loginService" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition"
p:requestSuffix="-request" p:responseSuffix="-response" >
<property name="schemaCollection" ref="schemaCollection" />
<property name="portTypeName" value="LoginService"/>
<property name="locationUri" value="loginService"/>
</bean>
<!-- here I set the xsd files to generate the wsdl -->
<bean id="schemaCollection"
class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
<property name="xsds">
<list>
<value>classpath:login-service.xsd</value>
</list>
</property>
</bean>
<!-- EXCEPTION RESOLVER -->
<!-- bean id="exceptionResolver" class="ro.isdc.weather.service.exception.WeatherExceptionResolver">
</bean-->
<!-- ENDPOINT MAPPING INTERCEPTOR -->
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
<property name="interceptors">
<list>
<!-- ref bean="wsSecurityInterceptor" /-->
<ref local="schemaInterceptor"/>
</list>
</property>
</bean>
<!-- SCHEMA INTERCEPTOR -->
<bean id="schemaInterceptor" class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
<property name="schema" value="classpath:login-service.xsd"/>
<property name="validateRequest" value="true"/>
</bean>
<!-- SECURITY INTERCEPTOR -->
<bean id="wsSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
<property name="validationActions" value="UsernameToken" />
<property name="validationCallbackHandler" ref="callbackHandler" />
</bean>
<!-- CALLBACK HANDLER -->
<bean id="callbackHandler" class="org.springframework.ws.soap.security.wss4j.callback.SimplePasswordValidationCallbackHandler">
<property name="users">
<props>
<prop key="user1">passwd1</prop>
<prop key="user2">passwd2</prop>
</props>
</property>
</bean>
</beans>
これは、web.xmlファイルである:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>SOAP Web Service</display-name>
<servlet>
<servlet-name>spring-ws</servlet-name>
<servlet-class>
org.springframework.ws.transport.http.MessageDispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/spring-ws-context.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>spring-ws</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
はどうもありがとうございました!それはエンドポイントとして設定するためにあなたのLoginEndpointは設定でこのエントリで、@Endpointアノテーションを付けるべきである
あなたは春と春-WS JARを持っていますか? – skaffman
spring 3.0.5.RELEASEとspring-ws 2.0.0.RELEASEです – DaJackal