SWS-667 - Improve SWS namespace

This commit is contained in:
Arjen Poutsma
2010-12-16 16:46:28 +00:00
parent 218c72253b
commit df9d82ac0f
9 changed files with 569 additions and 56 deletions

View File

@@ -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<BeanMetadataElement> argumentResolvers = new ManagedList<BeanMetadataElement>();
argumentResolvers.setSource(source);
ManagedList<BeanMetadataElement> returnValueHandlers = new ManagedList<BeanMetadataElement>();
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;
}
}

View File

@@ -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 &lt;sws:dynamic-wsdl/&gt;} 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<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"));
}
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;
}
}

View File

@@ -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 =

View File

@@ -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 &lt;sws:static-wsdl/&gt;} 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);
}
}

View File

@@ -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());
}
}

View File

@@ -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 =

View File

@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns="http://www.springframework.org/schema/web-services" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
<xsd:schema xmlns="http://www.springframework.org/schema/web-services"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:tool="http://www.springframework.org/schema/tool"
targetNamespace="http://www.springframework.org/schema/web-services" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/schema/beans"/>
<xsd:import namespace="http://www.springframework.org/schema/tool"/>
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" />
<xsd:import namespace="http://www.springframework.org/schema/tool" schemaLocation="http://www.springframework.org/schema/tool/spring-tool-3.0.xsd" />
<xsd:annotation>
<xsd:documentation>
@@ -14,49 +15,37 @@
</xsd:documentation>
</xsd:annotation>
<xsd:element name="marshalling-endpoints">
<xsd:element name="annotation-driven">
<xsd:annotation>
<xsd:documentation
source="java:org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter">
Indicates that a unmarshaller should be used to convert incoming request
messages into method parameters, and return values marshalled into a response message.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:exports
type="org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter"/>
</tool:annotation>
</xsd:appinfo>
<xsd:documentation source="java:org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter"><![CDATA[
Configures the annotation-driven Spring WS endpoint programming model.
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attribute name="unmarshaller" type="xsd:string" default="marshaller">
<xsd:attribute name="marshaller" type="xsd:string">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.oxm.Unmarshaller">
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'.
</xsd:documentation>
<xsd:documentation source="java:org.springframework.oxm.Marshaller"><![CDATA[
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 a custom, non-JAXB2 marshaller is used.
JAXB2 marshallers are detected automatically.]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.oxm.Unmarshaller"/>
<tool:expected-type type="java:org.springframework.oxm.Marshaller"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="marshaller" type="xsd:string" default="marshaller">
<xsd:attribute name="unmarshaller" type="xsd:string">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.oxm.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'.
</xsd:documentation>
<xsd:documentation source="java:org.springframework.oxm.Unmarshaller"><![CDATA[
The bean name of the Unmarshaller that is to be used to convert objects into XML.
This attribute is not required, and only needs to be specified
explicitly if a custom, non-JAXB2 unmarshaller is used.
JAXB2 marshallers are detected automatically.]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.oxm.Marshaller"/>
<tool:expected-type type="java:org.springframework.oxm.Unmarshaller"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
@@ -64,35 +53,128 @@
</xsd:complexType>
</xsd:element>
<xsd:element name="xpath-endpoints">
<xsd:element name="static-wsdl">
<xsd:annotation>
<xsd:documentation
source="java:org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter">
Indicates that a endpoints using @XPathParam annotations should be detected.
<xsd:documentation source="java:org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition"><![CDATA[
Exposes a static WSDL file.
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:attribute name="location" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation><![CDATA[
The location of the WSDL file to expose, as a Spring resource location: a URL, a "classpath:" pseudo URL, or a
relative file path.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="dynamic-wsdl">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
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.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:exports
type="org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="namespace" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Bind a namespace URI to a prefix
</xsd:documentation>
</xsd:annotation>
<xsd:element name="xsd" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="prefix" type="xsd:string" use="required"/>
<xsd:attribute name="uri" type="xsd:string" use="required"/>
<xsd:annotation>
<xsd:documentation>An XSD schema to base the WSDL on.</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="location" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation>
The location of the XSD file, as a Spring resource location: a URL, a "classpath:"
pseudo URL, or a relative file path.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:ID" use="required">
<xsd:annotation>
<xsd:documentation>The unique identifier for the wsdl.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="portTypeName" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation>Sets the port type name used for this definition.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="targetNamespace" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Sets the target namespace used for this definition. Defaults to the target namespace of the XSD.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="requestSuffix" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Sets the suffix used to detect request elements in the schema. Defaults to 'Request'.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="responseSuffix" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Sets the suffix used to detect response elements in the schema. Defaults to 'Response'.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="faultSuffix" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Sets the suffix used to detect fault elements in the schema. Defaults to 'Fault'.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="createSoap11Binding" type="xsd:boolean" default="true">
<xsd:annotation>
<xsd:documentation>
Indicates whether a SOAP 1.1 binding should be created. Defaults to true.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="createSoap12Binding" type="xsd:boolean" default="false">
<xsd:annotation>
<xsd:documentation>
Indicates whether a SOAP 1.2 binding should be created. Defaults to false.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="transportUri" type="xsd:anyURI" default="http://schemas.xmlsoap.org/soap/http">
<xsd:annotation>
<xsd:documentation>
Sets the value used for the binding transport attribute value. Defaults to HTTP.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="locationUri" type="xsd:anyURI">
<xsd:annotation>
<xsd:documentation>
Sets the value used for the SOAP Address location attribute value.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="serviceName" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Sets the service name. Defaults to the port type name, with the suffix 'Service'
appended to it.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:schema>

View File

@@ -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<String, SimpleWsdl11Definition> 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<String, ?> 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());
}
}

View File

@@ -0,0 +1,16 @@
<?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: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://static.springframework.org/schema/web-services/web-services-2.0.xsd">
<sws:static-wsdl location="classpath:org/springframework/ws/client/support/destination/simple.wsdl"/>
<sws:dynamic-wsdl id="single" portTypeName="Order">
<sws:xsd location="classpath:/org/springframework/ws/wsdl/wsdl11/single.xsd"/>
</sws:dynamic-wsdl>
</beans>