diff --git a/core/src/main/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParser.java b/core/src/main/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParser.java new file mode 100644 index 00000000..fcd9689b --- /dev/null +++ b/core/src/main/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParser.java @@ -0,0 +1,188 @@ +/* + * 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 + * + * 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. + */ + +package org.springframework.ws.config; + +import org.springframework.beans.BeanMetadataElement; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.RuntimeBeanReference; +import org.springframework.beans.factory.parsing.BeanComponentDefinition; +import org.springframework.beans.factory.parsing.CompositeComponentDefinition; +import org.springframework.beans.factory.support.ManagedList; +import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.factory.xml.BeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.util.ClassUtils; +import org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter; +import org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor; +import org.springframework.ws.server.endpoint.adapter.method.MessageContextMethodArgumentResolver; +import org.springframework.ws.server.endpoint.adapter.method.SourcePayloadMethodProcessor; +import org.springframework.ws.server.endpoint.adapter.method.StaxPayloadMethodArgumentResolver; +import org.springframework.ws.server.endpoint.adapter.method.XPathParamMethodArgumentResolver; +import org.springframework.ws.server.endpoint.adapter.method.dom.Dom4jPayloadMethodProcessor; +import org.springframework.ws.server.endpoint.adapter.method.dom.DomPayloadMethodProcessor; +import org.springframework.ws.server.endpoint.adapter.method.dom.JDomPayloadMethodProcessor; +import org.springframework.ws.server.endpoint.adapter.method.dom.XomPayloadMethodProcessor; +import org.springframework.ws.server.endpoint.adapter.method.jaxb.JaxbElementPayloadMethodProcessor; +import org.springframework.ws.server.endpoint.adapter.method.jaxb.XmlRootElementPayloadMethodProcessor; +import org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping; +import org.springframework.ws.soap.server.endpoint.adapter.method.SoapMethodArgumentResolver; +import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping; + +import org.w3c.dom.Element; + +/** + * {@link BeanDefinitionParser} that parses the {@code annotation-driven} element to configure a Spring WS application. + * + * @author Arjen Poutsma + * @since 2.0 + */ +class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { + + private static final boolean dom4jPresent = + ClassUtils.isPresent("org.dom4j.Element", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); + + private static final boolean jaxb2Present = + ClassUtils.isPresent("javax.xml.bind.Binder", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); + + private static final boolean jdomPresent = + ClassUtils.isPresent("org.jdom.Element", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); + + private static final boolean staxPresent = ClassUtils + .isPresent("javax.xml.stream.XMLInputFactory", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); + + private static final boolean xomPresent = + ClassUtils.isPresent("nu.xom.Element", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); + + public BeanDefinition parse(Element element, ParserContext parserContext) { + Object source = parserContext.extractSource(element); + + CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source); + parserContext.pushContainingComponent(compDefinition); + + registerEndpointMappings(source, parserContext); + + registerEndpointAdapters(element, source, parserContext); + + parserContext.popAndRegisterContainingComponent(); + + return null; + } + + private void registerEndpointMappings(Object source, ParserContext parserContext) { + RootBeanDefinition payloadRootMappingDef = + createBeanDefinition(PayloadRootAnnotationMethodEndpointMapping.class, source); + payloadRootMappingDef.getPropertyValues().add("order", 0); + parserContext.getReaderContext().registerWithGeneratedName(payloadRootMappingDef); + + RootBeanDefinition soapActionMappingDef = + createBeanDefinition(SoapActionAnnotationMethodEndpointMapping.class, source); + soapActionMappingDef.getPropertyValues().add("order", 1); + parserContext.getReaderContext().registerWithGeneratedName(soapActionMappingDef); + } + + private void registerEndpointAdapters(Element element, Object source, ParserContext parserContext) { + RootBeanDefinition adapterDef = createBeanDefinition(DefaultMethodEndpointAdapter.class, source); + + ManagedList argumentResolvers = new ManagedList(); + argumentResolvers.setSource(source); + + ManagedList returnValueHandlers = new ManagedList(); + returnValueHandlers.setSource(source); + + argumentResolvers.add(createBeanDefinition(MessageContextMethodArgumentResolver.class, source)); + argumentResolvers.add(createBeanDefinition(XPathParamMethodArgumentResolver.class, source)); + argumentResolvers.add(createBeanDefinition(SoapMethodArgumentResolver.class, source)); + + RuntimeBeanReference domProcessor = createBeanReference(DomPayloadMethodProcessor.class, source, parserContext); + argumentResolvers.add(domProcessor); + returnValueHandlers.add(domProcessor); + + RuntimeBeanReference sourceProcessor = + createBeanReference(SourcePayloadMethodProcessor.class, source, parserContext); + argumentResolvers.add(sourceProcessor); + returnValueHandlers.add(sourceProcessor); + + if (dom4jPresent) { + RuntimeBeanReference dom4jProcessor = + createBeanReference(Dom4jPayloadMethodProcessor.class, source, parserContext); + argumentResolvers.add(dom4jProcessor); + returnValueHandlers.add(dom4jProcessor); + } + if (jaxb2Present) { + RuntimeBeanReference xmlRootElementProcessor = + createBeanReference(XmlRootElementPayloadMethodProcessor.class, source, parserContext); + argumentResolvers.add(xmlRootElementProcessor); + returnValueHandlers.add(xmlRootElementProcessor); + + RuntimeBeanReference jaxbElementProcessor = + createBeanReference(JaxbElementPayloadMethodProcessor.class, source, parserContext); + argumentResolvers.add(jaxbElementProcessor); + returnValueHandlers.add(jaxbElementProcessor); + } + if (jdomPresent) { + RuntimeBeanReference jdomProcessor = + createBeanReference(JDomPayloadMethodProcessor.class, source, parserContext); + argumentResolvers.add(jdomProcessor); + returnValueHandlers.add(jdomProcessor); + } + if (staxPresent) { + argumentResolvers.add(createBeanDefinition(StaxPayloadMethodArgumentResolver.class, source)); + } + if (xomPresent) { + RuntimeBeanReference xomProcessor = + createBeanReference(XomPayloadMethodProcessor.class, source, parserContext); + argumentResolvers.add(xomProcessor); + returnValueHandlers.add(xomProcessor); + } + if (element.hasAttribute("marshaller")) { + RuntimeBeanReference marshallerReference = new RuntimeBeanReference(element.getAttribute("marshaller")); + RuntimeBeanReference unmarshallerReference; + if (element.hasAttribute("unmarshaller")) { + unmarshallerReference = new RuntimeBeanReference(element.getAttribute("unmarshaller")); + } + else { + unmarshallerReference = marshallerReference; + } + + RootBeanDefinition marshallingProcessorDef = + createBeanDefinition(MarshallingPayloadMethodProcessor.class, source); + marshallingProcessorDef.getPropertyValues().add("marshaller", marshallerReference); + marshallingProcessorDef.getPropertyValues().add("unmarshaller", unmarshallerReference); + argumentResolvers.add(marshallingProcessorDef); + returnValueHandlers.add(marshallingProcessorDef); + } + + adapterDef.getPropertyValues().add("methodArgumentResolvers", argumentResolvers); + adapterDef.getPropertyValues().add("methodReturnValueHandlers", returnValueHandlers); + + parserContext.getReaderContext().registerWithGeneratedName(adapterDef); + } + + private RuntimeBeanReference createBeanReference(Class beanClass, Object source, ParserContext parserContext) { + RootBeanDefinition beanDefinition = createBeanDefinition(beanClass, source); + String beanName = parserContext.getReaderContext().registerWithGeneratedName(beanDefinition); + parserContext.registerComponent(new BeanComponentDefinition(beanDefinition, beanName)); + return new RuntimeBeanReference(beanName); + } + + private RootBeanDefinition createBeanDefinition(Class beanClass, Object source) { + RootBeanDefinition beanDefinition = new RootBeanDefinition(beanClass); + beanDefinition.setSource(source); + beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); + return beanDefinition; + } +} diff --git a/core/src/main/java/org/springframework/ws/config/DynamicWsdlBeanDefinitionParser.java b/core/src/main/java/org/springframework/ws/config/DynamicWsdlBeanDefinitionParser.java new file mode 100644 index 00000000..5c50e4ee --- /dev/null +++ b/core/src/main/java/org/springframework/ws/config/DynamicWsdlBeanDefinitionParser.java @@ -0,0 +1,90 @@ +/* + * 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 + * + * 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. + */ + +package org.springframework.ws.config; + +import java.util.List; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.support.AbstractBeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +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.StringUtils; +import org.springframework.util.xml.DomUtils; +import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; +import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection; + +import org.w3c.dom.Element; + +/** + * Parser for the {@code <sws:dynamic-wsdl/>} element. + * + * @author Arjen Poutsma + * @since 2.0 + */ +class DynamicWsdlBeanDefinitionParser extends AbstractBeanDefinitionParser { + + @Override + protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { + Object source = parserContext.extractSource(element); + + BeanDefinitionBuilder wsdlBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultWsdl11Definition.class); + wsdlBuilder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); + wsdlBuilder.getRawBeanDefinition().setSource(source); + + addProperty(element, wsdlBuilder, "portTypeName"); + addProperty(element, wsdlBuilder, "targetNamespace"); + addProperty(element, wsdlBuilder, "requestSuffix"); + addProperty(element, wsdlBuilder, "responseSuffix"); + addProperty(element, wsdlBuilder, "faultSuffix"); + addProperty(element, wsdlBuilder, "createSoap11Binding"); + addProperty(element, wsdlBuilder, "createSoap12Binding"); + addProperty(element, wsdlBuilder, "transportUri"); + addProperty(element, wsdlBuilder, "locationUri"); + addProperty(element, wsdlBuilder, "serviceName"); + + List schemas = DomUtils.getChildElementsByTagName(element, "xsd"); + RootBeanDefinition collectionDef = createBeanDefinition(CommonsXsdSchemaCollection.class, source); + collectionDef.getPropertyValues().addPropertyValue("inline", "true"); + ManagedList xsds = new ManagedList(); + 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); + return wsdlBuilder.getBeanDefinition(); + } + + private void addProperty(Element element, BeanDefinitionBuilder builder, String propertyName) { + String propertyValue = element.getAttribute(propertyName); + if (StringUtils.hasText(propertyValue)) { + builder.addPropertyValue(propertyName, propertyValue); + } + } + + private RootBeanDefinition createBeanDefinition(Class beanClass, Object source) { + RootBeanDefinition beanDefinition = new RootBeanDefinition(beanClass); + beanDefinition.setSource(source); + beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); + return beanDefinition; + } + +} diff --git a/core/src/main/java/org/springframework/ws/config/MarshallingEndpointsBeanDefinitionParser.java b/core/src/main/java/org/springframework/ws/config/MarshallingEndpointsBeanDefinitionParser.java index 1af9de4f..36c07aba 100644 --- a/core/src/main/java/org/springframework/ws/config/MarshallingEndpointsBeanDefinitionParser.java +++ b/core/src/main/java/org/springframework/ws/config/MarshallingEndpointsBeanDefinitionParser.java @@ -5,7 +5,7 @@ * 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, @@ -29,7 +29,9 @@ import org.w3c.dom.Element; * * @author Arjen Poutsma * @since 1.5.0 + * @deprecated as of Spring Web Services 2.0, in favor of {@link AnnotationDrivenBeanDefinitionParser} */ +@Deprecated class MarshallingEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser { private static final String GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME = diff --git a/core/src/main/java/org/springframework/ws/config/StaticWsdlBeanDefinitionParser.java b/core/src/main/java/org/springframework/ws/config/StaticWsdlBeanDefinitionParser.java new file mode 100644 index 00000000..5758061b --- /dev/null +++ b/core/src/main/java/org/springframework/ws/config/StaticWsdlBeanDefinitionParser.java @@ -0,0 +1,71 @@ +/* + * 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 + * + * 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. + */ + +package org.springframework.ws.config; + +import org.springframework.beans.factory.BeanDefinitionStoreException; +import org.springframework.beans.factory.support.AbstractBeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.util.StringUtils; + +import org.w3c.dom.Element; + +/** + * Parser for the {@code <sws:static-wsdl/>} element. + * + * @author Arjen Poutsma + * @since 2.0 + */ +class StaticWsdlBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { + + private static final String CLASS_NAME = "org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition"; + + @Override + protected boolean shouldGenerateIdAsFallback() { + return true; + } + + @Override + protected String getBeanClassName(Element element) { + return CLASS_NAME; + } + + @Override + protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) + throws BeanDefinitionStoreException { + String id = element.getAttribute(ID_ATTRIBUTE); + if (StringUtils.hasLength(id)) { + return id; + } + String location = element.getAttribute("location"); + if (StringUtils.hasLength(location)) { + String filename = StringUtils.stripFilenameExtension(StringUtils.getFilename(location)); + if (StringUtils.hasLength(filename)) { + return filename; + } + } + return parserContext.getReaderContext().generateBeanName(definition); + } + + @Override + protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) { + String location = element.getAttribute("location"); + beanDefinitionBuilder.addPropertyValue("wsdl", location); + } + +} diff --git a/core/src/main/java/org/springframework/ws/config/WebServicesNamespaceHandler.java b/core/src/main/java/org/springframework/ws/config/WebServicesNamespaceHandler.java index e53370fc..71071cc2 100644 --- a/core/src/main/java/org/springframework/ws/config/WebServicesNamespaceHandler.java +++ b/core/src/main/java/org/springframework/ws/config/WebServicesNamespaceHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2007 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, @@ -28,7 +28,10 @@ import org.springframework.beans.factory.xml.NamespaceHandlerSupport; public class WebServicesNamespaceHandler extends NamespaceHandlerSupport { public void init() { + registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenBeanDefinitionParser()); registerBeanDefinitionParser("marshalling-endpoints", new MarshallingEndpointsBeanDefinitionParser()); registerBeanDefinitionParser("xpath-endpoints", new XPathEndpointsBeanDefinitionParser()); + registerBeanDefinitionParser("static-wsdl", new StaticWsdlBeanDefinitionParser()); + registerBeanDefinitionParser("dynamic-wsdl", new DynamicWsdlBeanDefinitionParser()); } } diff --git a/core/src/main/java/org/springframework/ws/config/XPathEndpointsBeanDefinitionParser.java b/core/src/main/java/org/springframework/ws/config/XPathEndpointsBeanDefinitionParser.java index 3dd712e9..24641e02 100644 --- a/core/src/main/java/org/springframework/ws/config/XPathEndpointsBeanDefinitionParser.java +++ b/core/src/main/java/org/springframework/ws/config/XPathEndpointsBeanDefinitionParser.java @@ -5,7 +5,7 @@ * 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, @@ -31,7 +31,9 @@ import org.w3c.dom.Element; * * @author Arjen Poutsma * @since 1.5.0 + * @deprecated as of Spring Web Services 2.0, in favor of {@link AnnotationDrivenBeanDefinitionParser} */ +@Deprecated class XPathEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser { private static final String XPATH_PARAM_ANNOTATION_METHOD_ENDPOINT_ADAPTER_CLASS_NAME = diff --git a/core/src/main/resources/org/springframework/ws/config/web-services-2.0.xsd b/core/src/main/resources/org/springframework/ws/config/web-services-2.0.xsd index 0430f31c..2999a1f6 100644 --- a/core/src/main/resources/org/springframework/ws/config/web-services-2.0.xsd +++ b/core/src/main/resources/org/springframework/ws/config/web-services-2.0.xsd @@ -1,12 +1,13 @@ - - - + + @@ -14,49 +15,37 @@ - + - - Indicates that a unmarshaller should be used to convert incoming request - messages into method parameters, and return values marshalled into a response message. - - - - - - + - + - - The bean name of the Unmarshaller that is to be used to convert XML into objects. - - This attribute is not required, and only needs to be specified - explicitly if the bean name of the desired Unmarshaller - is not 'marshaller'. - + - + - + - - The bean name of the Marshaller that is to be used to convert objects into XML. - - This attribute is not required, and only needs to be specified - explicitly if the bean name of the desired Marshaller - is not 'marshaller'. - + - + @@ -64,35 +53,128 @@ - + - - Indicates that a endpoints using @XPathParam annotations should be detected. + + + + + + + + + + + + + + + + + + + Exposes a dynamic WSDL file, creating a SOAP 1.1 or 1.2 binding based on naming conventions in one or + more inlined XSD schemas. - - - - - - - - - Bind a namespace URI to a prefix - - + - - + + An XSD schema to base the WSDL on. + + + + + The location of the XSD file, as a Spring resource location: a URL, a "classpath:" + pseudo URL, or a relative file path. + + + + + + The unique identifier for the wsdl. + + + + + Sets the port type name used for this definition. + + + + + + Sets the target namespace used for this definition. Defaults to the target namespace of the XSD. + + + + + + + Sets the suffix used to detect request elements in the schema. Defaults to 'Request'. + + + + + + + Sets the suffix used to detect response elements in the schema. Defaults to 'Response'. + + + + + + + Sets the suffix used to detect fault elements in the schema. Defaults to 'Fault'. + + + + + + + Indicates whether a SOAP 1.1 binding should be created. Defaults to true. + + + + + + + Indicates whether a SOAP 1.2 binding should be created. Defaults to false. + + + + + + + Sets the value used for the binding transport attribute value. Defaults to HTTP. + + + + + + + Sets the value used for the SOAP Address location attribute value. + + + + + + + Sets the service name. Defaults to the port type name, with the suffix 'Service' + appended to it. + + + - diff --git a/core/src/test/java/org/springframework/ws/config/WsdlBeanDefinitionParserTest.java b/core/src/test/java/org/springframework/ws/config/WsdlBeanDefinitionParserTest.java new file mode 100644 index 00000000..a86f70b7 --- /dev/null +++ b/core/src/test/java/org/springframework/ws/config/WsdlBeanDefinitionParserTest.java @@ -0,0 +1,59 @@ +/* + * 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 + * + * 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. + */ + +package org.springframework.ws.config; + +import java.util.Map; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; +import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition; +import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Arjen Poutsma + */ +public class WsdlBeanDefinitionParserTest { + + private ApplicationContext applicationContext; + + @Before + public void setUp() throws Exception { + applicationContext = new ClassPathXmlApplicationContext("wsdlBeanDefinitionParserTest.xml", getClass()); + } + + @Test + public void staticWsdl() throws Exception { + Map result = applicationContext.getBeansOfType(SimpleWsdl11Definition.class); + Assert.assertFalse("no WSDL definitions found", result.isEmpty()); + String beanName = result.keySet().iterator().next(); + Assert.assertEquals("invalid bean name", "simple", beanName); + } + + @Test + public void dynamicWsdl() throws Exception { + Map result = applicationContext.getBeansOfType(DefaultWsdl11Definition.class); + Assert.assertFalse("no WSDL definitions found", result.isEmpty()); + + result = applicationContext.getBeansOfType(CommonsXsdSchemaCollection.class); + Assert.assertFalse("no XSD definitions found", result.isEmpty()); + } +} diff --git a/core/src/test/resources/org/springframework/ws/config/wsdlBeanDefinitionParserTest.xml b/core/src/test/resources/org/springframework/ws/config/wsdlBeanDefinitionParserTest.xml new file mode 100644 index 00000000..cfabd36d --- /dev/null +++ b/core/src/test/resources/org/springframework/ws/config/wsdlBeanDefinitionParserTest.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + +