Java spring ws-SOAP端点不可访问的spring引导

Java spring ws-SOAP端点不可访问的spring引导,java,spring,web-services,soap,spring-boot,Java,Spring,Web Services,Soap,Spring Boot,我在玩弄,遇到了一个问题。 创建RESTful Web服务非常容易。但我无法使用spring boot运行soap服务 实际上,我的项目具有spring boot starter web依赖性 是否需要一个尚未存在的额外sprint启动程序 有哪些变通办法? 如果我有一个用于SOAP服务的web.xml,我可以在初始化过程中以某种方式包含它吗?我知道已经有一个类似的问题了,但它并没有解决我的问题,因为这个问题是基于SpringWeb的。所以我想我的问题在别的地方 我的soap Web服务的端点如

我在玩弄,遇到了一个问题。 创建RESTful Web服务非常容易。但我无法使用spring boot运行soap服务

实际上,我的项目具有spring boot starter web依赖性

是否需要一个尚未存在的额外sprint启动程序

有哪些变通办法? 如果我有一个用于SOAP服务的web.xml,我可以在初始化过程中以某种方式包含它吗?我知道已经有一个类似的问题了,但它并没有解决我的问题,因为这个问题是基于SpringWeb的。所以我想我的问题在别的地方

我的soap Web服务的端点如下所示:

@Endpoint
public class MyEndpoint {


    @PayloadRoot(localPart = "myRequest", namespace = "my.ns")
    @ResponsePayload
    public TResponse logRequest(@RequestPayload final TRequest request) {
        //some code
    }
//more methods
}
端点在一个xml中组合在一起,由spring boot通过
ImportResource
注释加载

我的初级课程是这样的:

@Configuration
@EnableAutoConfiguration
@ImportResource({ "classpath:/my/pack/app.xml" }) //soap-endpoint is configured here. 
public class Example {

    public static void main(final String[] args) {
        SpringApplication.run(Example.class, args);
    }
}
端点的配置

<?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"
    xmlns:web-services="http://www.springframework.org/schema/web-services"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <context:component-scan base-package="my.pack.webservice.service.endpoint" />

    <mvc:annotation-driven />

    <bean id="task"
        class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition"
        p:portTypeName="Task" p:locationUri="/taskService/" p:requestSuffix="-request"
        p:responseSuffix="-response">
        <property name="schema">
            <bean class="org.springframework.xml.xsd.SimpleXsdSchema" p:xsd="classpath:/task.xsd" />
        </property>
    </bean>

    <bean
        class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
    </bean>

    <bean id="messageReceiver"
        class="org.springframework.ws.soap.server.SoapMessageDispatcher">
        <property name="endpointAdapters">
            <list>
                <ref bean="defaultMethodEndpointAdapter" />
            </list>
        </property>
    </bean>


    <bean id="messageFactory"
        class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
        <property name="payloadCaching" value="true" />
    </bean>

    <bean id="defaultMethodEndpointAdapter"
        class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter">
        <property name="methodArgumentResolvers">
            <list>
                <ref bean="marshallingPayloadMethodProcessor" />
            </list>
        </property>
        <property name="methodReturnValueHandlers">
            <list>
                <ref bean="marshallingPayloadMethodProcessor" />
            </list>
        </property>
    </bean>

    <bean id="marshallingPayloadMethodProcessor"
        class="org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor">
        <constructor-arg ref="marshaller" />
        <constructor-arg ref="marshaller" />
    </bean>


    <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"
        p:contextPath="my.pack.task.schema.beans">
        <property name="contextPaths">
            <list>
                <value>my.pack.task.schema.beans</value>
            </list>
        </property>
    </bean>

    <bean id="taskEndpoint"
        class="my.pack.reporting.webservice.service.endpoint.TaskEndpoint">
        <property name="taskService" ref="taskDatastoreService" />
    </bean>

    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="mappings">
            <props>
                <prop key="*.wsdl">task</prop>
            </props>
        </property>
        <property name="defaultHandler" ref="messageReceiver" />
    </bean>

</beans>
Spring启动启动日志:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::             (v0.5.0.M7)

2014-01-14 14:59:30.196  INFO 15210 --- [           main] my.pack.Example                         : Starting Example on mango with PID 15210 (/home/myuser/Code/test/spring-boot-tryout/target/spring-boot-tryout-0.0.1-SNAPSHOT.jar started by myuser)
2014-01-14 14:59:30.250  INFO 15210 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4d8f36ef: startup date [Tue Jan 14 14:59:30 CET 2014]; root of context hierarchy
2014-01-14 14:59:30.624  INFO 15210 --- [           main] o.s.b.f.xml.XmlBeanDefinitionReader      : Loading XML bean definitions from class path resource [my/pack/app.xml]
2014-01-14 14:59:30.750  INFO 15210 --- [           main] o.s.b.f.xml.XmlBeanDefinitionReader      : Loading XML bean definitions from class path resource [my/pack/subpack/application-context-persistence.xml]
2014-01-14 14:59:31.216  INFO 15210 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'org.springframework.transaction.config.internalTransactionAdvisor': replacing [Root bean: class [org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration; factoryMethodName=transactionAdvisor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class]]
2014-01-14 14:59:31.243  INFO 15210 --- [           main] a.ConfigurationClassBeanDefinitionReader : Skipping bean definition for [BeanMethod:name=transactionManager,declaringClass=org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration]: a definition for bean 'transactionManager' already exists. This top-level bean definition is considered as an override.
2014-01-14 14:59:31.244  INFO 15210 --- [           main] a.ConfigurationClassBeanDefinitionReader : Skipping bean definition for [BeanMethod:name=entityManagerFactory,declaringClass=org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration]: a definition for bean 'entityManagerFactory' already exists. This top-level bean definition is considered as an override.
2014-01-14 14:59:31.504  WARN 15210 --- [           main] my.pack.common.config.AppSettings       : ConfigFilePath is blank, using default configuration
2014-01-14 14:59:31.587  INFO 15210 --- [           main] my.pack.common.config.ConfigValidator   : Beginning to validate the configuration
2014-01-14 14:59:31.710  INFO 15210 --- [           main] my.pack.common.config.ConfigValidator   : Validating finished
2014-01-14 14:59:31.913  INFO 15210 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerByCGLIB$$a83839b9] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-01-14 14:59:31.972  INFO 15210 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-01-14 14:59:31.990  INFO 15210 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-01-14 14:59:32.007  INFO 15210 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-01-14 14:59:32.302  INFO 15210 --- [           main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 9001
2014-01-14 14:59:32.539  INFO 15210 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2014-01-14 14:59:32.539  INFO 15210 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/7.0.47
2014-01-14 14:59:32.630  INFO 15210 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2014-01-14 14:59:32.630  INFO 15210 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2384 ms
2014-01-14 14:59:41.357  INFO 15210 --- [ost-startStop-1] o.a.catalina.util.SessionIdGenerator     : Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [7,997] milliseconds.
2014-01-14 14:59:41.376  INFO 15210 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2014-01-14 14:59:41.376  INFO 15210 --- [ost-startStop-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2014-01-14 14:59:41.537  INFO 15210 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-01-14 14:59:41.782  INFO 15210 --- [ost-startStop-1] o.s.j.d.DriverManagerDataSource          : Loaded JDBC driver: org.h2.Driver
2014-01-14 14:59:41.851  INFO 15210 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'reporting'
2014-01-14 14:59:42.107  INFO 15210 --- [ost-startStop-1] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
2014-01-14 14:59:42.124  INFO 15210 --- [ost-startStop-1] org.hibernate.Version                    : HHH000412: Hibernate Core {4.2.8.Final}
2014-01-14 14:59:42.131  INFO 15210 --- [ost-startStop-1] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2014-01-14 14:59:42.134  INFO 15210 --- [ost-startStop-1] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2014-01-14 14:59:42.179  INFO 15210 --- [ost-startStop-1] org.hibernate.ejb.Ejb3Configuration      : HHH000204: Processing PersistenceUnitInfo [
    name: reporting
    ...]
2014-01-14 14:59:42.421  INFO 15210 --- [ost-startStop-1] o.h.s.j.c.i.ConnectionProviderInitiator  : HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
2014-01-14 14:59:42.731  INFO 15210 --- [ost-startStop-1] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2014-01-14 14:59:43.016  INFO 15210 --- [ost-startStop-1] o.h.e.t.i.TransactionFactoryInitiator    : HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory
2014-01-14 14:59:43.025  INFO 15210 --- [ost-startStop-1] o.h.h.i.ast.ASTQueryTranslatorFactory    : HHH000397: Using ASTQueryTranslatorFactory
2014-01-14 14:59:43.415  INFO 15210 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000227: Running hbm2ddl schema export
Hibernate: alter table report drop constraint FK_5ld65a9c14kdtwywxr6262vdl
2014-01-14 14:59:43.421 ERROR 15210 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000389: Unsuccessful: alter table report drop constraint FK_5ld65a9c14kdtwywxr6262vdl
2014-01-14 14:59:43.422 ERROR 15210 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport  : Tabelle "REPORT" nicht gefunden
Table "REPORT" not found; SQL statement:
alter table report drop constraint FK_5ld65a9c14kdtwywxr6262vdl [42102-174]
Hibernate: alter table task drop constraint FK_o2by8kw6mmcb95r8eq3jx074e
2014-01-14 14:59:43.422 ERROR 15210 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000389: Unsuccessful: alter table task drop constraint FK_o2by8kw6mmcb95r8eq3jx074e
2014-01-14 14:59:43.422 ERROR 15210 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport  : Tabelle "TASK" nicht gefunden
Table "TASK" not found; SQL statement:
alter table task drop constraint FK_o2by8kw6mmcb95r8eq3jx074e [42102-174]
Hibernate: drop table customer if exists
Hibernate: drop table report if exists
Hibernate: drop table task if exists
Hibernate: create table customer (id bigint generated by default as identity, identifier varchar(255) not null, primary key (id))
Hibernate: create table report (id bigint generated by default as identity, description varchar(255), occurred bigint not null, resolved bigint not null, status integer not null, customer_id bigint not null, primary key (id))
Hibernate: create table task (id bigint generated by default as identity, description varchar(255), finished bigint, started bigint, status integer not null, customer_id bigint not null, primary key (id))
Hibernate: alter table customer add constraint UK_nonbx33y5nkpeeohhjs6r18c0 unique (identifier)
Hibernate: alter table report add constraint FK_5ld65a9c14kdtwywxr6262vdl foreign key (customer_id) references customer
Hibernate: alter table task add constraint FK_o2by8kw6mmcb95r8eq3jx074e foreign key (customer_id) references customer
2014-01-14 14:59:43.863  INFO 15210 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000230: Schema export complete
2014-01-14 14:59:44.141  INFO 15210 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-01-14 14:59:44.141  INFO 15210 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-01-14 14:59:44.344  INFO 15210 --- [ost-startStop-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 2967 ms
2014-01-14 14:59:44.858  INFO 15210 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2014-01-14 14:59:44.949  INFO 15210 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port: 9001
2014-01-14 14:59:44.950  INFO 15210 --- [           main] my.pack.Example                         : Started Example in 15.343 seconds (JVM running for 15.914)
谢谢你的帮助

更新:我实际使用的代码非常有效,您可以在此处查看:
Spring WS不需要
MessageDispatcherServlet
?因此,您需要将默认的
DispatcherServlet
替换为其中一个,例如

@Bean
public MessageDispatcherServlet dispatcherServlet() {
    return new MessageDispatcherServlet();
}

请发布终结点XML文件,并打开日志以查看它是否真正正确加载。@chrylis我添加了日志输出和终结点配置您几乎肯定不想在XML中使用
(它与SOAP无关,但它也会在启动时关闭负载)。@DaveSyer好的,我删除了那一行。您也可以在
DispatcherServlet
中使用Spring Webservices,请参见。我想我希望它在那时可以工作,但也许``是个问题?添加
MessageDispatcherServlet
并让它加载xml配置不是更容易吗?如果调用正确,Spring Boot应该注册在上下文中找到的其他servlet?或者可以添加一个
WebApplicationInitializer
来添加servlet。这样,您就可以使用正常的方式引导
MessageDispatcherServlet
@Dave Syer。我尝试过将代码剪掉,添加了上下文配置位置,但我现在没有看到任何wsdl url被映射@你能提供一个代码样本吗?我有一些关于
WebApplicationInitializer
的代码,但我记得从未调用过
onStartup
方法。我不知道使用代码片段是否是最佳做法,但如果我在构造函数中使用带有有效配置位置的
XmlWebApplicationContext
,它会起作用。非常感谢。
@Bean
public MessageDispatcherServlet dispatcherServlet() {
    return new MessageDispatcherServlet();
}