Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Spring WS和JAXB的AbstractMethodEndpointMapping中的AbstractMethodError_Java_Web Services_Soap_Jaxb_Spring Ws - Fatal编程技术网

Java 使用Spring WS和JAXB的AbstractMethodEndpointMapping中的AbstractMethodError

Java 使用Spring WS和JAXB的AbstractMethodEndpointMapping中的AbstractMethodError,java,web-services,soap,jaxb,spring-ws,Java,Web Services,Soap,Jaxb,Spring Ws,我正在尝试使用SpringWS和JAXB创建一个示例SOAPWeb服务,我遇到了一个异常,我不知道为什么 我将jetty用作具有以下配置的服务器: 当我使用地址从浏览器访问wsdl时:我可以看到wsdl。有趣的是,如果我写一个地址,它也能工作 但当我使用soapUI发出请求时,我会得到一个堆栈跟踪: 2012-01-05 13:07:30.010::WARN: /loginService/ java.lang.AbstractMethodError: org.springframework.

我正在尝试使用SpringWS和JAXB创建一个示例SOAPWeb服务,我遇到了一个异常,我不知道为什么

我将jetty用作具有以下配置的服务器:

当我使用地址从浏览器访问wsdl时:我可以看到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)
以下是登录点:

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>

使MessageDispatchServlet能够调用需要OXM编组的方法。
类路径:login-service.xsd
密码1
密码2
这是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>

soapweb服务
春季天气预报
org.springframework.ws.transport.http.MessageDispatcherServlet
上下文配置位置
类路径:/spring-ws-context.xml
春季天气预报
/*

多谢各位

您的登录点应使用@EndPoint annotation进行注释,并在配置中使用此项将其配置为端点:

 <sws:annotation-driven />


您有哪些Spring和Spring WS-jar?Spring 3.0.5.RELEASE和Spring WS-it是2.0.0.RELEASE