I am playing around with spring-boot and i run into a problem.
To create RESTful webservices is quite easy. But i am not able to run an soap service with spring-boot.
Actually my Project hast the spring-boot-starter-web dependency.
Is there an extra sprint-boot-starter needed that does not yet exist?
What are some workarounds?
If i have a web.xml for the SOAP service can i include it somehow in the initialization process? I know that a similar question already exists, but it did not solve my problem because the question there is based on spring-web. So i think my Problem is somewhere else.
The Endpoint of my soap-webservice looks like this one:
@Endpoint
public class MyEndpoint {
@PayloadRoot(localPart = "myRequest", namespace = "my.ns")
@ResponsePayload
public TResponse logRequest(@RequestPayload final TRequest request) {
//some code
}
//more methods
}
The endpoint is weird together in an xml which is loaded by spring-boot via the ImportResource
annotation.
So my starter class looks like this:
@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);
}
}
The configuration of the endpoint
<?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>
In addition to that, in case i have a faulty dependency i attach the maven dependency tree:
[INFO] [dependency:tree {execution: default-cli}]
[INFO] de.trao:spring-boot-tryout:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:0.5.0.M7:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:0.5.0.M7:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:0.5.0.M7:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:0.5.0.M7:compile
[INFO] | | - org.springframework.boot:spring-boot-starter-logging:jar:0.5.0.M7:compile
[INFO] | | +- org.slf4j:jcl-over-slf4j:jar:1.7.5:compile
[INFO] | | +- org.slf4j:jul-to-slf4j:jar:1.7.5:compile
[INFO] | | +- org.slf4j:log4j-over-slf4j:jar:1.7.5:compile
[INFO] | | - ch.qos.logback:logback-classic:jar:1.0.13:compile
[INFO] | | - ch.qos.logback:logback-core:jar:1.0.13:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:0.5.0.M7:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:7.0.47:compile
[INFO] | | - org.apache.tomcat.embed:tomcat-embed-logging-juli:jar:7.0.47:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.3.0:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.0:compile
[INFO] | | - com.fasterxml.jackson.core:jackson-core:jar:2.3.0:compile
[INFO] | +- org.springframework:spring-web:jar:4.0.0.RELEASE:compile
[INFO] | | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | | +- org.springframework:spring-beans:jar:4.0.0.RELEASE:compile
[INFO] | | - org.springframework:spring-core:jar:4.0.0.RELEASE:compile
[INFO] | - org.springframework:spring-webmvc:jar:4.0.0.RELEASE:compile
[INFO] | - org.springframework:spring-expression:jar:4.0.0.RELEASE:compile
[INFO] +- my.pack:my-soap-serv:jar:0.0.1-SNAPSHOT:compile
[INFO] | +- org.springframework:spring-context:jar:4.0.0.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.0.0.RELEASE:compile
[INFO] | +- org.springframework:spring-aspects:jar:4.0.0.RELEASE:compile
[INFO] | | +- org.aspectj:aspectjweaver:jar:1.7.4:compile (version managed from 1.8.0.M1)
[INFO] | | - org.springframework:spring-context-support:jar:4.0.0.RELEASE:compile
[INFO] | +- org.springframework:spring-oxm:jar:4.0.0.RELEASE:compile
[INFO] | +- org.springframework.ws:spring-ws-core:jar:2.1.4.RELEASE:compile
[INFO] | | +- org.springframework.ws:spring-xml:jar:2.1.4.RELEASE:compile
[INFO] | | +- wsdl4j:wsdl4j:jar:1.6.1:compile
[INFO] | | - javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | +- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.6.5:compile
[INFO] | +- my.pack:datastore:jar:0.0.1-SNAPSHOT:compile
[INFO] | | +- com.googlecode.genericdao:dao:jar:1.2.0:compile
[INFO] | | | - com.googlecode.genericdao:search:jar:1.2.0:compile
[INFO] | | +- com.googlecode.genericdao:search-jpa-hibernate:jar:1.2.0:compile
[INFO] | | | - com.googlecode.genericdao:search-hibernate:jar:1.2.0:compile
[INFO] | | +- org.hibernate:hibernate-entitymanager:jar:4.2.8.Final:compile
[INFO] | | | +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile
[INFO] | | | +- org.hibernate:hibernate-core:jar:4.2.8.Final:compile
[INFO] | | | | - antlr:antlr:jar:2.7.7:compile
[INFO] | | | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | | +- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] | | | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.1.Final:compile
[INFO] | | | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] | | | - org.hibernate.common:hibernate-commons-annotations:jar:4.0.2.Final:compile
[INFO] | | +- org.springframework:spring-orm:jar:4.0.0.RELEASE:compile
[INFO] | | | - org.springframework:spring-tx:jar:4.0.0.RELEASE:compile
[INFO] | | +- org.springframework:spring-jdbc:jar:4.0.0.RELEASE:compile
[INFO] | | - com.google.guava:guava:jar:15.0:compile
[INFO] | +- org.apache.ws.commons.axiom:axiom:jar:1.2.5:compile
[INFO] | +- my.pack:shared:jar:0.0.1-SNAPSHOT:compile
[INFO] | - my.pack:common:jar:1.0.0-SNAPSHOT:compile
[INFO] | +- com.typesafe:config:jar:1.0.2:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.5:compile (version managed from 1.7.2)
[INFO] | +- commons-lang:commons-lang:jar:2.6:compile
[INFO] | - com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] +- com.h2database:h2:jar:1.3.174:compile
[INFO] +- junit:junit:jar:4.11:test
[INFO] | - org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.mockito:mockito-core:jar:1.9.5:test
[INFO] | - org.objenesis:objenesis:jar:1.0:test
[INFO] - org.hamcrest:hamcrest-library:jar:1.3:test
Spring boot start log:
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _
( ( )\___ | '_ | '_| | '_ / _` |
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: 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 : Overri
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…