Upgrade samples to new namespace
This commit is contained in:
@@ -25,9 +25,11 @@ import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
|
||||
import org.springframework.xml.xsd.SimpleXsdSchema;
|
||||
import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
@@ -40,6 +42,9 @@ import org.w3c.dom.Element;
|
||||
*/
|
||||
class DynamicWsdlBeanDefinitionParser extends AbstractBeanDefinitionParser {
|
||||
|
||||
private static final boolean commonsSchemaPresent = ClassUtils.isPresent("org.apache.ws.commons.schema.XmlSchema",
|
||||
DynamicWsdlBeanDefinitionParser.class.getClassLoader());
|
||||
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
||||
Object source = parserContext.extractSource(element);
|
||||
@@ -60,16 +65,30 @@ class DynamicWsdlBeanDefinitionParser extends AbstractBeanDefinitionParser {
|
||||
addProperty(element, wsdlBuilder, "serviceName");
|
||||
|
||||
List<Element> schemas = DomUtils.getChildElementsByTagName(element, "xsd");
|
||||
RootBeanDefinition collectionDef = createBeanDefinition(CommonsXsdSchemaCollection.class, source);
|
||||
collectionDef.getPropertyValues().addPropertyValue("inline", "true");
|
||||
ManagedList<String> xsds = new ManagedList<String>();
|
||||
xsds.setSource(source);
|
||||
for (Element schema : schemas) {
|
||||
xsds.add(schema.getAttribute("location"));
|
||||
if (commonsSchemaPresent) {
|
||||
RootBeanDefinition collectionDef = createBeanDefinition(CommonsXsdSchemaCollection.class, source);
|
||||
collectionDef.getPropertyValues().addPropertyValue("inline", "true");
|
||||
ManagedList<String> xsds = new ManagedList<String>();
|
||||
xsds.setSource(source);
|
||||
for (Element schema : schemas) {
|
||||
xsds.add(schema.getAttribute("location"));
|
||||
}
|
||||
collectionDef.getPropertyValues().addPropertyValue("xsds", xsds);
|
||||
String collectionName = parserContext.getReaderContext().registerWithGeneratedName(collectionDef);
|
||||
wsdlBuilder.addPropertyReference("schemaCollection", collectionName);
|
||||
}
|
||||
else {
|
||||
if (schemas.size() > 1) {
|
||||
throw new IllegalArgumentException(
|
||||
"Multiple <xsd/> elements requires Commons XMLSchema." +
|
||||
"Please put Commons XMLSchema on the classpath.");
|
||||
}
|
||||
RootBeanDefinition schemaDef = createBeanDefinition(SimpleXsdSchema.class, source);
|
||||
Element schema = schemas.iterator().next();
|
||||
schemaDef.getPropertyValues().addPropertyValue("xsd", schema.getAttribute("location"));
|
||||
String schemaName = parserContext.getReaderContext().registerWithGeneratedName(schemaDef);
|
||||
wsdlBuilder.addPropertyReference("schema", schemaName);
|
||||
}
|
||||
collectionDef.getPropertyValues().addPropertyValue("xsds", xsds);
|
||||
String collectionName = parserContext.getReaderContext().registerWithGeneratedName(collectionDef);
|
||||
wsdlBuilder.addPropertyReference("schemaCollection", collectionName);
|
||||
return wsdlBuilder.getBeanDefinition();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
* Copyright 2005-2010 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
|
||||
* 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,
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.ws.samples.echo.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.ws.samples.echo.service.EchoService;
|
||||
|
||||
/**
|
||||
@@ -24,6 +25,7 @@ import org.springframework.ws.samples.echo.service.EchoService;
|
||||
* @author Ingo Siebert
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Service
|
||||
public class EchoServiceImpl implements EchoService {
|
||||
|
||||
public String echo(String s) {
|
||||
|
||||
@@ -1,73 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:sws="http://www.springframework.org/schema/web-services"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
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">
|
||||
|
||||
<description>
|
||||
This web application context contains Spring-WS beans. The beans defined in this context are automatically
|
||||
detected by Spring-WS, similar to the way Controllers are picked up in Spring Web MVC.
|
||||
</description>
|
||||
|
||||
<bean id="payloadMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
|
||||
<description>
|
||||
This endpoint mapping uses the qualified name of the payload (body contents) to determine the endpoint for
|
||||
an incoming message. Every message is passed to the default endpoint. Additionally, messages are logged
|
||||
using the logging interceptor.
|
||||
</description>
|
||||
<property name="interceptors">
|
||||
<list>
|
||||
<ref local="validatingInterceptor"/>
|
||||
<ref local="loggingInterceptor"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
<context:component-scan base-package="org.springframework.ws.samples.echo"/>
|
||||
|
||||
<bean id="validatingInterceptor"
|
||||
class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
|
||||
<description>
|
||||
This interceptor validates both incoming and outgoing message contents according to the 'echo.xsd' XML
|
||||
Schema file.
|
||||
</description>
|
||||
<property name="xsdSchema" ref="schema"/>
|
||||
<property name="validateRequest" value="true"/>
|
||||
<property name="validateResponse" value="true"/>
|
||||
</bean>
|
||||
<sws:annotation-driven />
|
||||
|
||||
<bean class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter"/>
|
||||
<sws:interceptors>
|
||||
<bean class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
|
||||
<description>
|
||||
This interceptor validates both incoming and outgoing message contents according to the 'echo.xsd' XML
|
||||
Schema file.
|
||||
</description>
|
||||
<property name="schema" value="/WEB-INF/echo.xsd"/>
|
||||
<property name="validateRequest" value="true"/>
|
||||
<property name="validateResponse" value="true"/>
|
||||
</bean>
|
||||
<bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor">
|
||||
<description>
|
||||
This interceptor logs the message payload.
|
||||
</description>
|
||||
</bean>
|
||||
</sws:interceptors>
|
||||
|
||||
<bean id="loggingInterceptor" class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor">
|
||||
<description>
|
||||
This interceptor logs the message payload.
|
||||
</description>
|
||||
</bean>
|
||||
|
||||
<bean id="echoEndpoint" class="org.springframework.ws.samples.echo.ws.EchoEndpoint">
|
||||
<description>
|
||||
This endpoint handles echo requests.
|
||||
</description>
|
||||
<constructor-arg ref="echoService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="echo" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
|
||||
<description>
|
||||
This bean definition represents a WSDL definition that is generated at runtime. It can be retrieved by
|
||||
going to /echo/echo.wsdl (i.e. the bean name corresponds to the filename).
|
||||
</description>
|
||||
<property name="schema" ref="schema"/>
|
||||
<property name="portTypeName" value="Echo"/>
|
||||
<property name="locationUri" value="http://localhost:8080/echo/services"/>
|
||||
</bean>
|
||||
|
||||
<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
|
||||
<description>
|
||||
This bean definition contains the XSD schema.
|
||||
</description>
|
||||
<property name="xsd" value="/WEB-INF/echo.xsd"/>
|
||||
</bean>
|
||||
|
||||
<bean id="echoService" class="org.springframework.ws.samples.echo.service.impl.EchoServiceImpl">
|
||||
<description>
|
||||
This bean is our "business" service.
|
||||
</description>
|
||||
</bean>
|
||||
<sws:dynamic-wsdl id="echo" portTypeName="Echo" locationUri="http://localhost:8080/echo/services">
|
||||
<sws:xsd location="/WEB-INF/echo.xsd"/>
|
||||
</sws:dynamic-wsdl>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user