Reworked tutorial sample to code config
This commit is contained in:
@@ -13,8 +13,8 @@ apply plugin: 'idea'
|
||||
apply plugin: 'war'
|
||||
apply plugin: 'tomcat'
|
||||
|
||||
ext.springVersion = '3.2.4.RELEASE'
|
||||
ext.springWsVersion = '2.1.4.RELEASE'
|
||||
ext.springVersion = '4.0.2.RELEASE'
|
||||
ext.springWsVersion = '2.2.0.BUILD-SNAPSHOT'
|
||||
ext.tomcatVersion = '7.0.42'
|
||||
|
||||
dependencies {
|
||||
@@ -22,7 +22,11 @@ dependencies {
|
||||
compile("org.jdom:jdom:2.0.1")
|
||||
runtime("jaxen:jaxen:1.1.4")
|
||||
runtime("log4j:log4j:1.2.16")
|
||||
|
||||
runtime("org.apache.ws.xmlschema:xmlschema-core:2.1.0")
|
||||
runtime("wsdl4j:wsdl4j:1.6.1")
|
||||
|
||||
providedCompile("javax.servlet:javax.servlet-api:3.0.1")
|
||||
|
||||
testCompile("junit:junit:4.10")
|
||||
testCompile("org.easymock:easymock:3.1")
|
||||
|
||||
@@ -35,6 +39,7 @@ dependencies {
|
||||
|
||||
repositories {
|
||||
maven { url 'http://repo.spring.io/libs-release' }
|
||||
maven { url 'http://repo.spring.io/libs-snapshot' }
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.mycompany.hr.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.ws.config.annotation.EnableWs;
|
||||
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
|
||||
import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@EnableWs
|
||||
@Configuration
|
||||
@ComponentScan("com.mycompany.hr")
|
||||
public class HRConfiguration {
|
||||
|
||||
@Bean
|
||||
public DefaultWsdl11Definition holiday() {
|
||||
DefaultWsdl11Definition definition = new DefaultWsdl11Definition();
|
||||
definition.setPortTypeName("HumanResource");
|
||||
definition.setLocationUri("/holidayService/");
|
||||
definition.setTargetNamespace("http://mycompany.com/hr/definitions");
|
||||
definition.setSchemaCollection(holidayXsd());
|
||||
return definition;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CommonsXsdSchemaCollection holidayXsd() {
|
||||
CommonsXsdSchemaCollection collection =
|
||||
new CommonsXsdSchemaCollection(new Resource[] { new ClassPathResource("/hr.xsd")});
|
||||
collection.setInline(true);
|
||||
return collection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mycompany.hr.config;
|
||||
|
||||
import org.springframework.ws.transport.http.support.AbstractAnnotationConfigMessageDispatcherServletInitializer;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class HRServletInitializer
|
||||
extends AbstractAnnotationConfigMessageDispatcherServletInitializer {
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getRootConfigClasses() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getServletConfigClasses() {
|
||||
return new Class<?>[]{HRConfiguration.class};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTransformWsdlLocations() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getServletMappings() {
|
||||
return new String[]{"/*"};
|
||||
}
|
||||
}
|
||||
0
tutorial/src/main/webapp/EMPTY
Normal file
0
tutorial/src/main/webapp/EMPTY
Normal file
@@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2007 the original author or authors.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<!--This WSDL file is here for illustration purposes. It is not used by the holidayService, which dynamically creates
|
||||
the WSDL based on the hr.xsd schema. The dynamically created WSDL is very similar to this WSDL, however. -->
|
||||
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
xmlns:schema="http://mycompany.com/hr/schemas"
|
||||
xmlns:tns="http://mycompany.com/hr/definitions"
|
||||
targetNamespace="http://mycompany.com/hr/definitions">
|
||||
<wsdl:types>
|
||||
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<xsd:import namespace="http://mycompany.com/hr/schemas" schemaLocation="hr.xsd"/>
|
||||
</xsd:schema>
|
||||
</wsdl:types>
|
||||
<wsdl:message name="HolidayRequest">
|
||||
<wsdl:part element="schema:HolidayRequest" name="HolidayRequest">
|
||||
</wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:portType name="HumanResource">
|
||||
<wsdl:operation name="Holiday">
|
||||
<wsdl:input message="tns:HolidayRequest" name="HolidayRequest">
|
||||
</wsdl:input>
|
||||
</wsdl:operation>
|
||||
</wsdl:portType>
|
||||
<wsdl:binding name="HumanResourceBinding" type="tns:HumanResource">
|
||||
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
||||
<wsdl:operation name="Holiday">
|
||||
<soap:operation soapAction=""/>
|
||||
<wsdl:input name="HolidayRequest">
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
</wsdl:operation>
|
||||
</wsdl:binding>
|
||||
<wsdl:service name="HumanResourceService">
|
||||
<wsdl:port binding="tns:HumanResourceBinding" name="HumanResourcePort">
|
||||
<soap:address location="http://localhost:8080/holidayService/"/>
|
||||
</wsdl:port>
|
||||
</wsdl:service>
|
||||
</wsdl:definitions>
|
||||
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2007 the original author or authors.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:sws="http://www.springframework.org/schema/web-services"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.mycompany.hr"/>
|
||||
|
||||
<sws:annotation-driven/>
|
||||
|
||||
<sws:dynamic-wsdl id="holiday" portTypeName="HumanResource" locationUri="/holidayService/"
|
||||
targetNamespace="http://mycompany.com/hr/definitions">
|
||||
<sws:xsd location="/WEB-INF/hr.xsd"/>
|
||||
</sws:dynamic-wsdl>
|
||||
|
||||
</beans>
|
||||
@@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2007 the original author or authors.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||
version="2.4">
|
||||
|
||||
<display-name>MyCompany HR Holiday Service</display-name>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>spring-ws</servlet-name>
|
||||
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>transformWsdlLocations</param-name>
|
||||
<param-value>true</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>spring-ws</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
</web-app>
|
||||
Reference in New Issue
Block a user