From a833243ac2bfdf28b9de78154fd0bf10d99e5d9c Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Sat, 8 Mar 2008 02:47:59 +0000 Subject: [PATCH] Done working on WSDL in sandbox. --- sandbox/pom.xml | 4 +- .../wsdl/wsdl11/DefaultWsdl11Definition.java | 159 ++++++++ .../ws/wsdl/wsdl11/DomWsdl11Definition.java | 158 -------- .../wsdl11/ProviderBasedWsdl4jDefinition.java | 114 ++++++ .../wsdl11/XsdSchemaWsdl11Definition.java | 290 --------------- .../provider/AbstractPortTypesProvider.java | 232 ++++++++++++ .../BindingsProvider.java} | 13 +- .../provider/DefaultConcretePartProvider.java | 305 +++++++++++++++ .../provider/DefaultMessagesProvider.java | 124 +++++++ .../provider/DefaultServiceProvider.java | 95 ----- .../wsdl11/provider/ImportsProvider.java} | 19 +- .../InliningXsdSchemaTypesProvider.java | 109 ++++++ .../MessagesProvider.java} | 16 +- .../wsdl11/provider/PortTypesProvider.java | 34 ++ .../wsdl11/provider/ServicesProvider.java | 34 ++ .../wsdl/wsdl11/provider/Soap11Provider.java | 345 +++++++++++++++++ .../wsdl/wsdl11/provider/Soap12Provider.java | 348 ++++++++++++++++++ .../ws/wsdl/wsdl11/provider/SoapProvider.java | 112 ++++++ .../SuffixBasedPortTypesProvider.java | 156 ++++++++ .../TypesProvider.java} | 14 +- .../ws/wsdl/wsdl11/provider/package.html | 5 + .../soap/AbstractSoapWsdl11Definition.java | 209 ----------- .../wsdl11/soap/Soap11Wsdl11Definition.java | 40 -- .../wsdl11/soap/Soap12Wsdl11Definition.java | 40 -- .../wsdl11/soap/SoapWsdl11Definition.java | 124 ------- .../wsdl/wsdl11/visitor/BindingVisitor.java | 46 --- .../wsdl11/visitor/DefaultBindingVisitor.java | 186 ---------- .../wsdl11/visitor/DefaultServiceVisitor.java | 127 ------- .../wsdl/wsdl11/visitor/MessageVisitor.java | 35 -- .../wsdl/wsdl11/visitor/PortTypeVisitor.java | 46 --- .../wsdl/wsdl11/visitor/ServiceVisitor.java | 37 -- .../ws/wsdl/wsdl11/visitor/TypesVisitor.java | 32 -- .../commons/CommonsXsdSchemaCollection.java | 112 ------ .../wsdl11/DefaultWsdl11DefinitionTest.java | 75 ++++ .../wsdl11/XsdSchemaWsdl11DefinitionTest.java | 51 --- .../provider/DefaultMessagesProviderTest.java | 89 +++++ .../InliningXsdSchemaTypesProviderTest.java | 92 +++++ .../wsdl11/provider/Soap11ProviderTest.java | 142 +++++++ .../wsdl11/provider/Soap12ProviderTest.java | 142 +++++++ .../wsdl11/provider/SoapProviderTest.java | 102 +++++ .../SuffixBasedPortTypesProviderTest.java | 69 ++++ .../wsdl11/soap/SoapWsdl11DefinitionTest.java | 75 ---- .../visitor/DefaultBindingVisitorTest.java | 83 ----- .../CommonsXsdSchemaCollectionTest.java | 67 ---- .../ws/wsdl/wsdl11/provider/A.xsd | 10 + .../ws/wsdl/wsdl11/provider/ABC.xsd | 16 + .../ws/wsdl/wsdl11/provider/B.xsd | 14 + .../ws/wsdl/wsdl11/{ => provider}/C.xsd | 0 .../ws/wsdl/wsdl11/{ => provider}/D.xsd | 0 .../ws/wsdl/wsdl11/provider/schema.xsd | 35 ++ .../ws/wsdl/wsdl11/soap/portType.wsdl | 13 - .../defaultBindingVisitorTest-expected.wsdl | 37 -- .../defaultBindingVisitorTest-input.wsdl | 27 -- 53 files changed, 2902 insertions(+), 1957 deletions(-) create mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11Definition.java delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/DomWsdl11Definition.java create mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/ProviderBasedWsdl4jDefinition.java delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/XsdSchemaWsdl11Definition.java create mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/AbstractPortTypesProvider.java rename sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/{visitor/WsdlVisitor.java => provider/BindingsProvider.java} (62%) create mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultConcretePartProvider.java create mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProvider.java delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultServiceProvider.java rename sandbox/src/main/java/org/springframework/{xml/xsd/XsdSchemaCollection.java => ws/wsdl/wsdl11/provider/ImportsProvider.java} (62%) create mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProvider.java rename sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/{visitor/ImportVisitor.java => provider/MessagesProvider.java} (61%) create mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/PortTypesProvider.java create mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ServicesProvider.java create mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11Provider.java create mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12Provider.java create mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProvider.java create mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProvider.java rename sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/{visitor/DefinitionVisitor.java => provider/TypesProvider.java} (64%) create mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/package.html delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/AbstractSoapWsdl11Definition.java delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/Soap11Wsdl11Definition.java delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/Soap12Wsdl11Definition.java delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/SoapWsdl11Definition.java delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/BindingVisitor.java delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/DefaultBindingVisitor.java delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/DefaultServiceVisitor.java delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/MessageVisitor.java delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/PortTypeVisitor.java delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/ServiceVisitor.java delete mode 100644 sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/TypesVisitor.java delete mode 100644 sandbox/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollection.java create mode 100644 sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11DefinitionTest.java delete mode 100644 sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/XsdSchemaWsdl11DefinitionTest.java create mode 100644 sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProviderTest.java create mode 100644 sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProviderTest.java create mode 100644 sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11ProviderTest.java create mode 100644 sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12ProviderTest.java create mode 100644 sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProviderTest.java create mode 100644 sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProviderTest.java delete mode 100644 sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/soap/SoapWsdl11DefinitionTest.java delete mode 100644 sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/visitor/DefaultBindingVisitorTest.java delete mode 100644 sandbox/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollectionTest.java create mode 100644 sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/A.xsd create mode 100644 sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/ABC.xsd create mode 100644 sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/B.xsd rename sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/{ => provider}/C.xsd (100%) rename sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/{ => provider}/D.xsd (100%) create mode 100644 sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/schema.xsd delete mode 100644 sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/soap/portType.wsdl delete mode 100644 sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/visitor/defaultBindingVisitorTest-expected.wsdl delete mode 100644 sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/visitor/defaultBindingVisitorTest-input.wsdl diff --git a/sandbox/pom.xml b/sandbox/pom.xml index 87bf3154..3ae491c4 100644 --- a/sandbox/pom.xml +++ b/sandbox/pom.xml @@ -68,9 +68,7 @@ org.springframework - spring-jmx - ${spring.version} - test + spring-test diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11Definition.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11Definition.java new file mode 100644 index 00000000..5e282e34 --- /dev/null +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11Definition.java @@ -0,0 +1,159 @@ +/* + * Copyright 2008 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.wsdl.wsdl11; + +import java.util.Properties; +import javax.xml.transform.Source; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.util.StringUtils; +import org.springframework.ws.wsdl.wsdl11.provider.DefaultMessagesProvider; +import org.springframework.ws.wsdl.wsdl11.provider.InliningXsdSchemaTypesProvider; +import org.springframework.ws.wsdl.wsdl11.provider.SoapProvider; +import org.springframework.ws.wsdl.wsdl11.provider.SuffixBasedPortTypesProvider; +import org.springframework.xml.xsd.XsdSchema; +import org.springframework.xml.xsd.XsdSchemaCollection; + +/** + * Convenient implementation of {@link Wsdl11Definition} that creates a SOAP 1.1 or 1.2 binding based on naming + * conventions in one or more inlined XSD schemas. Delegates to {@link InliningXsdSchemaTypesProvider}, {@link + * DefaultMessagesProvider}, {@link SuffixBasedPortTypesProvider}, {@link SoapProvider} underneath; effectively + * equivalent to using a {@link ProviderBasedWsdl4jDefinition} with all these providers. + * + * @author Arjen Poutsma + * @since 1.5.0 + */ +public class DefaultWsdl11Definition implements Wsdl11Definition, InitializingBean { + + private final InliningXsdSchemaTypesProvider typesProvider = new InliningXsdSchemaTypesProvider(); + + private final DefaultMessagesProvider messagesProvider = new DefaultMessagesProvider(); + + private final SuffixBasedPortTypesProvider portTypesProvider = new SuffixBasedPortTypesProvider(); + + private final SoapProvider soapProvider = new SoapProvider(); + + private final ProviderBasedWsdl4jDefinition delegate = new ProviderBasedWsdl4jDefinition(); + + private String serviceName; + + /** Creates a new instance of the {@link DefaultWsdl11Definition}. */ + public DefaultWsdl11Definition() { + delegate.setTypesProvider(typesProvider); + delegate.setMessagesProvider(messagesProvider); + delegate.setPortTypesProvider(portTypesProvider); + delegate.setBindingsProvider(soapProvider); + delegate.setServicesProvider(soapProvider); + } + + /** + * Sets the target namespace used for this definition. + *

+ * Defaults to the target namespace of the defined schema. + */ + public void setTargetNamespace(String targetNamespace) { + delegate.setTargetNamespace(targetNamespace); + } + + /** + * Sets the single XSD schema to inline. Either this property, or {@link #setSchemaCollection(XsdSchemaCollection) + * schemaCollection} must be set. + */ + public void setSchema(final XsdSchema schema) { + typesProvider.setSchema(schema); + } + + /** + * Sets the XSD schema collection to inline. Either this property, or {@link #setSchema(XsdSchema) schema} must be + * set. + */ + public void setSchemaCollection(XsdSchemaCollection schemaCollection) { + typesProvider.setSchemaCollection(schemaCollection); + } + + /** Sets the port type name used for this definition. Required. */ + public void setPortTypeName(String portTypeName) { + portTypesProvider.setPortTypeName(portTypeName); + } + + /** Sets the suffix used to detect request elements in the schema. */ + public void setRequestSuffix(String requestSuffix) { + portTypesProvider.setRequestSuffix(requestSuffix); + } + + /** Sets the suffix used to detect response elements in the schema. */ + public void setResponseSuffix(String responseSuffix) { + portTypesProvider.setResponseSuffix(responseSuffix); + } + + /** Sets the suffix used to detect fault elements in the schema. */ + public void setFaultSuffix(String faultSuffix) { + portTypesProvider.setFaultSuffix(faultSuffix); + } + + /** Indicates whether a SOAP 1.1 binding should be created. */ + public void setCreateSoap11Binding(boolean createSoap11Binding) { + soapProvider.setCreateSoap11Binding(createSoap11Binding); + } + + /** Indicates whether a SOAP 1.2 binding should be created. */ + public void setCreateSoap12Binding(boolean createSoap12Binding) { + soapProvider.setCreateSoap12Binding(createSoap12Binding); + } + + /** + * Sets the SOAP Actions for this binding. Keys are {@link javax.wsdl.BindingOperation#getName() binding operation + * names}; values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}. + * + * @param soapActions the soap + */ + public void setSoapActions(Properties soapActions) { + soapProvider.setSoapActions(soapActions); + } + + /** Sets the value used for the binding transport attribute value. Defaults to HTTP. */ + public void setTransportUri(String transportUri) { + soapProvider.setTransportUri(transportUri); + } + + /** Sets the value used for the SOAP Address location attribute value. */ + public void setLocationUri(String locationUri) { + soapProvider.setLocationUri(locationUri); + } + + /** Sets the service name. */ + public void setServiceName(String serviceName) { + soapProvider.setServiceName(serviceName); + this.serviceName = serviceName; + } + + public void afterPropertiesSet() throws Exception { + if (!StringUtils.hasText(delegate.getTargetNamespace()) && typesProvider.getSchemaCollection() != null && + typesProvider.getSchemaCollection().getXsdSchemas().length > 0) { + XsdSchema schema = typesProvider.getSchemaCollection().getXsdSchemas()[0]; + setTargetNamespace(schema.getTargetNamespace()); + } + if (!StringUtils.hasText(serviceName) && StringUtils.hasText(portTypesProvider.getPortTypeName())) { + soapProvider.setServiceName(portTypesProvider.getPortTypeName() + "Service"); + } + delegate.afterPropertiesSet(); + } + + public Source getSource() { + return delegate.getSource(); + } +} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/DomWsdl11Definition.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/DomWsdl11Definition.java deleted file mode 100644 index 3019098e..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/DomWsdl11Definition.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2008 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.wsdl.wsdl11; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.Source; -import javax.xml.transform.dom.DOMSource; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.util.Assert; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public class DomWsdl11Definition implements Wsdl11Definition, InitializingBean { - - public static final String WSDL_NAMESPACE_URI = "http://schemas.xmlsoap.org/wsdl/"; - - public static final String WSDL_NAMESPACE_PREFIX = "wsdl"; - - public static final String TARGET_NAMESPACE_PREFIX = "tns"; - - private Document document; - - private String targetNamespace; - - public void setTargetNamespace(String targetNamespace) { - Assert.notNull(targetNamespace, "'targetNamespace' must not be null"); - this.targetNamespace = targetNamespace; - } - - public Source getSource() { - return new DOMSource(document); - } - - public void afterPropertiesSet() throws Exception { - Assert.notNull(targetNamespace, "'targetNamespace' is required"); - DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); - document = documentBuilder.newDocument(); - Element definitions = createDefinitions(document); - document.appendChild(definitions); - } - - public Element createDefinitions(Document document) { - Element definitions = createWsdlElement(document, "definitions"); - declareNamespaces(definitions); - definitions.setAttribute("targetNamespace", targetNamespace); - addImports(document, definitions); - addTypes(document, definitions); - addMessages(document, definitions); - addPortTypes(document, definitions); - addBindings(document, definitions); - addServices(document, definitions); - - return definitions; - } - - protected void declareNamespaces(Element definitions) { - declareNamespace(definitions, WSDL_NAMESPACE_PREFIX, WSDL_NAMESPACE_URI); - declareNamespace(definitions, TARGET_NAMESPACE_PREFIX, targetNamespace); - } - - protected void addImports(Document document, Element definitions) { - } - - protected void addTypes(Document document, Element definitions) { - } - - protected void addMessages(Document document, Element definitions) { - } - - protected void addPortTypes(Document document, Element definitions) { - } - - protected void addBindings(Document document, Element definitions) { - } - - protected void addServices(Document document, Element definitions) { - } - - protected void declareNamespace(Element element, String namespacePrefix, String namespaceUri) { - element.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + namespacePrefix, namespaceUri); - } - - protected Element createWsdlElement(Document document, String localName) { - return createElement(document, WSDL_NAMESPACE_PREFIX, WSDL_NAMESPACE_URI, localName); - } - - protected Element createElement(Document document, String namespacePrefix, String namespaceUri, String localName) { - Assert.hasLength(namespacePrefix, "No prefix given"); - Assert.hasLength(namespaceUri, "No namespace given"); - Assert.hasLength(localName, "No localName given"); - return document.createElementNS(namespaceUri, namespacePrefix + ":" + localName); - } - - protected List getWsdlChildElements(Element element, String localName) { - return getChildElements(element, WSDL_NAMESPACE_URI, localName); - } - - protected Element getWsdlChildElement(Element element, String localName) { - return getChildElement(element, WSDL_NAMESPACE_URI, localName); - } - - protected List getChildElements(Element element, String namespaceUri, String localName) { - Assert.hasLength(namespaceUri, "No namespace given"); - Assert.hasLength(localName, "No localName given"); - NodeList nodeList = element.getChildNodes(); - List result = new ArrayList(); - for (int i = 0; i < nodeList.getLength(); i++) { - Node node = nodeList.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE && namespaceUri.equals(node.getNamespaceURI()) && - localName.equals(node.getLocalName())) { - result.add(node); - } - } - return result; - } - - protected Element getChildElement(Element element, String namespaceUri, String localName) { - Assert.hasLength(namespaceUri, "No namespace given"); - Assert.hasLength(localName, "No localName given"); - NodeList nodeList = element.getChildNodes(); - for (int i = 0; i < nodeList.getLength(); i++) { - Node node = nodeList.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE && namespaceUri.equals(node.getNamespaceURI()) && - localName.equals(node.getLocalName())) { - return (Element) node; - } - } - return null; - } - - -} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/ProviderBasedWsdl4jDefinition.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/ProviderBasedWsdl4jDefinition.java new file mode 100644 index 00000000..861c5e57 --- /dev/null +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/ProviderBasedWsdl4jDefinition.java @@ -0,0 +1,114 @@ +/* + * Copyright 2008 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.wsdl.wsdl11; + +import javax.wsdl.Definition; +import javax.wsdl.WSDLException; +import javax.wsdl.factory.WSDLFactory; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.util.Assert; +import org.springframework.ws.wsdl.wsdl11.provider.BindingsProvider; +import org.springframework.ws.wsdl.wsdl11.provider.ImportsProvider; +import org.springframework.ws.wsdl.wsdl11.provider.MessagesProvider; +import org.springframework.ws.wsdl.wsdl11.provider.PortTypesProvider; +import org.springframework.ws.wsdl.wsdl11.provider.ServicesProvider; +import org.springframework.ws.wsdl.wsdl11.provider.TypesProvider; + +/** + * @author Arjen Poutsma + * @since 1.5.0 + */ +public class ProviderBasedWsdl4jDefinition extends Wsdl4jDefinition implements InitializingBean { + + /** The prefix used to register the target namespace in the WSDL. */ + public static final String TARGET_NAMESPACE_PREFIX = "tns"; + + private ImportsProvider importsProvider; + + private TypesProvider typesProvider; + + private MessagesProvider messagesProvider; + + private PortTypesProvider portTypesProvider; + + private BindingsProvider bindingsProvider; + + private ServicesProvider servicesProvider; + + private String targetNamespace; + + public void setImportsProvider(ImportsProvider importsProvider) { + this.importsProvider = importsProvider; + } + + public void setTypesProvider(TypesProvider typesProvider) { + this.typesProvider = typesProvider; + } + + public void setMessagesProvider(MessagesProvider messagesProvider) { + this.messagesProvider = messagesProvider; + } + + public void setPortTypesProvider(PortTypesProvider portTypesProvider) { + this.portTypesProvider = portTypesProvider; + } + + public void setBindingsProvider(BindingsProvider bindingsProvider) { + this.bindingsProvider = bindingsProvider; + } + + public void setServicesProvider(ServicesProvider servicesProvider) { + this.servicesProvider = servicesProvider; + } + + public String getTargetNamespace() { + return targetNamespace; + } + + /** Sets the target namespace used for this definition. Required. */ + public void setTargetNamespace(String targetNamespace) { + this.targetNamespace = targetNamespace; + } + + public void afterPropertiesSet() throws WSDLException { + Assert.notNull(getTargetNamespace(), "'targetNamespace' is required"); + WSDLFactory wsdlFactory = WSDLFactory.newInstance(); + Definition definition = wsdlFactory.newDefinition(); + definition.setTargetNamespace(getTargetNamespace()); + definition.addNamespace(TARGET_NAMESPACE_PREFIX, getTargetNamespace()); + if (importsProvider != null) { + importsProvider.addImports(definition); + } + if (typesProvider != null) { + typesProvider.addTypes(definition); + } + if (messagesProvider != null) { + messagesProvider.addMessages(definition); + } + if (portTypesProvider != null) { + portTypesProvider.addPortTypes(definition); + } + if (bindingsProvider != null) { + bindingsProvider.addBindings(definition); + } + if (servicesProvider != null) { + servicesProvider.addServices(definition); + } + setDefinition(definition); + } +} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/XsdSchemaWsdl11Definition.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/XsdSchemaWsdl11Definition.java deleted file mode 100644 index 402b51aa..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/XsdSchemaWsdl11Definition.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright 2008 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.wsdl.wsdl11; - -import java.io.IOException; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import javax.xml.parsers.DocumentBuilder; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Attr; -import org.xml.sax.SAXException; - -import org.springframework.core.io.Resource; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; -import org.springframework.xml.sax.SaxUtils; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public class XsdSchemaWsdl11Definition extends DomWsdl11Definition { - - public static final String XSD_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema"; - - public static final String XSD_NAMESPACE_PREFIX = "xsd"; - - private Resource[] schemaResources; - - private Element[] schemas; - - // keys are String namespaces; values are List of Elements - private Map namespaces = new LinkedHashMap(); - - public void setSchemas(Resource[] schemas) { - this.schemaResources = schemas; - } - - public void afterPropertiesSet() throws Exception { - Assert.notEmpty(schemaResources, "'schemas' is required"); - DocumentBuilder documentBuilder = createDocumentBuilder(); - schemas = new Element[schemaResources.length]; - for (int i = 0; i < schemaResources.length; i++) { - schemas[i] = parseSchema(documentBuilder, schemaResources[i]); - } - super.afterPropertiesSet(); - } - - protected void addTypes(Document document, Element definitions) { - Element types = createWsdlElement(document, "types"); - definitions.appendChild(types); - for (int i = 0; i < schemas.length; i++) { - Element importedSchema = (Element) document.importNode(schemas[i], true); - types.appendChild(importedSchema); - } - } - /* - protected void declareNamespaces(Element definitions) { - super.declareNamespaces(definitions); - declareNamespace(definitions, XSD_NAMESPACE_PREFIX, XSD_NAMESPACE_URI); - int i = 0; - for (Iterator iterator = namespaces.keySet().iterator(); iterator.hasNext();) { - String namespace = (String) iterator.next(); - declareNamespace(definitions, "s" + i, namespace); - i++; - } - } - - protected void addTypes(Document document, Element definitions) { - Element types = createWsdlElement(document, "types"); - definitions.appendChild(types); - for (Iterator iterator = namespaces.keySet().iterator(); iterator.hasNext();) { - String namespace = (String) iterator.next(); - List schemaElements = (List) namespaces.get(namespace); - addSchema(document, types, namespace, schemaElements); - } - } - - private void addSchema(Document document, Element types, String targetNamespace, List schemaElements) { - Element schema = createElement(document, XSD_NAMESPACE_PREFIX, XSD_NAMESPACE_URI, "schema"); - types.appendChild(schema); - schema.setAttribute("elementFormDefault", "qualified"); - schema.setAttribute("targetNamespace", targetNamespace); - for (Iterator iterator = schemaElements.iterator(); iterator.hasNext();) { - Element toBeImported = (Element) iterator.next(); - NodeList children = toBeImported.getChildNodes(); - for (int i = 0; i < children.getLength();i++) { - Node importedNode = document.importNode(children.item(i), true); - schema.appendChild(importedNode); - } - } - } - */ - - /* - protected void addTypes(Document document, Element definitions) { - Element types = createWsdlElement(document, "types"); - definitions.appendChild(types); - for (int i = 0; i < schemas.length; i++) { - addSchema(document, types, schemas[i]); - } - } - - private void addSchema(Document document, Element types, Resource xsdSchema) { - try { - DocumentBuilder documentBuilder = createDocumentBuilder(); - Element schema = parseSchema(documentBuilder, xsdSchema, null); - Element importedSchema = (Element) document.importNode(schema, true); - types.appendChild(importedSchema); - } - catch (ParserConfigurationException ex) { - throw new WsdlDefinitionException("Could not create DocumentBuilder", ex); - } - } - - - private Element parseSchema(DocumentBuilder documentBuilder, - Resource schemaResource, - String expectedTargetNamespace) { - try { - Document schemaDocument = documentBuilder.parse(SaxUtils.createInputSource(schemaResource)); - Element schema = schemaDocument.getDocumentElement(); - checkSchemaElement(schemaResource, expectedTargetNamespace, schema); - inlineIncludes(documentBuilder, schemaResource, schema); - return schema; - } - catch (Exception ex) { - throw new WsdlDefinitionException("Could parse schema " + schemaResource, ex); - } - } - - private void checkSchemaElement(Resource schemaResource, String expectedTargetNamespace, Element schema) { - Assert.isTrue("schema".equals(schema.getLocalName()), - schemaResource + " does not have 'schema' as root element local name"); - Assert.isTrue(XSD_NAMESPACE_URI.equals(schema.getNamespaceURI()), - schemaResource + " does not have '" + XSD_NAMESPACE_URI + "' as root element namespace"); - if (StringUtils.hasText(expectedTargetNamespace)) { - String targetNamespace = schema.getAttribute("targetNamespace"); - Assert.isTrue(!StringUtils.hasText(targetNamespace) || - expectedTargetNamespace.equals(targetNamespace), schemaResource + - " has invalid targetNamespace [" + targetNamespace + "]. Expected [" + expectedTargetNamespace + - "]"); - } - // check for elementFormDefault - } - - private void inlineIncludes(DocumentBuilder documentBuilder, Resource schemaResource, Element schema) - throws IOException { - List includes = getChildElements(schema, XSD_NAMESPACE_URI, "include"); - for (Iterator iterator = includes.iterator(); iterator.hasNext();) { - Element include = (Element) iterator.next(); - String schemaLocation = include.getAttribute("schemaLocation"); - Assert.hasText(schemaLocation, schemaResource + " has no schemaLocation attribute"); - Resource includedResource = schemaResource.createRelative(schemaLocation); - Assert.isTrue(includedResource.exists(), includedResource + " does not exist"); - String targetNamespace = schema.getAttribute("targetNamespace"); - Element includedSchemaElement = parseSchema(documentBuilder, includedResource, targetNamespace); - NodeList children = includedSchemaElement.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node importedChild = schema.getOwnerDocument().importNode(children.item(i), true); - schema.appendChild(importedChild); - } - schema.removeChild(include); - } - } - - private void findImports(Resource schemaResource, Element schema) throws IOException { - List imports = getChildElements(schema, XSD_NAMESPACE_URI, "import"); - for (Iterator iterator = imports.iterator(); iterator.hasNext();) { - Element importEl = (Element) iterator.next(); - String schemaLocation = importEl.getAttribute("schemaLocation"); - Assert.hasText(schemaLocation, schemaResource + " has no schemaLocation attribute"); - Resource includedResource = schemaResource.createRelative(schemaLocation); - - } - } - - private Element findNamespaces(DocumentBuilder documentBuilder, - Resource schemaResource, - Map namespaces, - String namespace) throws IOException, SAXException { - Document schemaDocument = documentBuilder.parse(SaxUtils.createInputSource(schemaResource)); - Element schema = schemaDocument.getDocumentElement(); - if (!StringUtils.hasText(namespace)) { - namespace = schema.getAttribute("targetNamespace"); - } - List elements = (List) namespaces.get(namespace); - if (elements == null) { - elements = new LinkedList(); - namespaces.put(namespace, elements); - } - NodeList children = schema.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - if (Node.ELEMENT_NODE == children.item(i).getNodeType() && - XSD_NAMESPACE_URI.equals(children.item(i).getNamespaceURI())) { - Element element = (Element) children.item(i); - if ("include".equals(element.getLocalName())) { - String schemaLocation = element.getAttribute("schemaLocation"); - Assert.hasText(schemaLocation, schemaResource + " has no schemaLocation attribute"); - Resource includedResource = schemaResource.createRelative(schemaLocation); - Assert.isTrue(includedResource.exists(), - includedResource + " (included from " + schemaResource + ") does not exist"); - Element includedSchema = findNamespaces(documentBuilder, includedResource, namespaces, namespace); - NodeList nodeList = includedSchema.getChildNodes(); - for (int j = 0; j < nodeList.getLength(); j++) { - Node importedNode = schema.getOwnerDocument().importNode(nodeList.item(j), true); - schema.appendChild(importedNode); - } - schema.removeChild(element); - } - else if ("import".equals(element.getLocalName())) { - String schemaLocation = element.getAttribute("schemaLocation"); - Assert.hasText(schemaLocation, schemaResource + " has no schemaLocation attribute"); - String importNamespace = element.getAttribute("namespace"); - Assert.hasText(importNamespace, schemaResource + " has no namespace attribute"); - Resource importedResource = schemaResource.createRelative(schemaLocation); - Assert.isTrue(importedResource.exists(), - importedResource + " (imported from " + schemaResource + ") does not exist"); - findNamespaces(documentBuilder, importedResource, namespaces, importNamespace); - element.removeAttribute("schemaLocation"); - elements.add(schema); - } - } - } - return schema; - } - */ - - - private Element parseSchema(DocumentBuilder documentBuilder, - Resource schemaResource) throws IOException, SAXException { - Document schemaDocument = documentBuilder.parse(SaxUtils.createInputSource(schemaResource)); - Element schema = schemaDocument.getDocumentElement(); - inlineIncludes(documentBuilder, schemaResource, schema); - return schema; - } - - private void inlineIncludes(DocumentBuilder documentBuilder, Resource schemaResource, Element schema) - throws IOException, SAXException { - List includes = getChildElements(schema, XSD_NAMESPACE_URI, "include"); - for (Iterator iterator = includes.iterator(); iterator.hasNext();) { - Element include = (Element) iterator.next(); - String schemaLocation = include.getAttribute("schemaLocation"); - Assert.hasText(schemaLocation, schemaResource + " has no schemaLocation attribute"); - Resource includedResource = schemaResource.createRelative(schemaLocation); - Assert.isTrue(includedResource.exists(), includedResource + " does not exist"); - String targetNamespace = schema.getAttribute("targetNamespace"); - Element includedSchemaElement = parseSchema(documentBuilder, includedResource); - NodeList children = includedSchemaElement.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node importedChild = schema.getOwnerDocument().importNode(children.item(i), true); - schema.appendChild(importedChild); - } - NamedNodeMap attributes = includedSchemaElement.getAttributes(); - for (int i = 0; i < attributes.getLength(); i++) { - Attr attribute = (Attr) attributes.item(i); - if ("http://www.w3.org/2000/xmlns/".equals(attribute.getNamespaceURI()) && - "xmlns".equals(attribute.getPrefix())) { - Attr importedAttr = (Attr) schema.getOwnerDocument().importNode(attribute, true); - schema.setAttributeNode(importedAttr); - } - } - schema.removeChild(include); - } - } - - -} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/AbstractPortTypesProvider.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/AbstractPortTypesProvider.java new file mode 100644 index 00000000..1716e35f --- /dev/null +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/AbstractPortTypesProvider.java @@ -0,0 +1,232 @@ +/* + * Copyright 2008 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.wsdl.wsdl11.provider; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import javax.wsdl.Definition; +import javax.wsdl.Fault; +import javax.wsdl.Input; +import javax.wsdl.Message; +import javax.wsdl.Operation; +import javax.wsdl.OperationType; +import javax.wsdl.Output; +import javax.wsdl.PortType; +import javax.wsdl.WSDLException; +import javax.xml.namespace.QName; + +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; + +/** + * Abstract base class for {@link PortTypesProvider} implementations. + * + * @author Arjen Poutsma + * @since 1.5.0 + */ +public abstract class AbstractPortTypesProvider implements PortTypesProvider { + + private String portTypeName; + + /** Returns the port type name used for this definition. */ + public String getPortTypeName() { + return portTypeName; + } + + /** Sets the port type name used for this definition. Required. */ + public void setPortTypeName(String portTypeName) { + this.portTypeName = portTypeName; + } + + /** + * Creates a single {@link PortType}, and calls {@link #populatePortType(Definition, PortType)} with it. + * + * @param definition the WSDL4J Definition + * @throws WSDLException in case of errors + */ + public void addPortTypes(Definition definition) throws WSDLException { + Assert.notNull(getPortTypeName(), "'portTypeName' is required"); + PortType portType = definition.createPortType(); + populatePortType(definition, portType); + createOperations(definition, portType); + portType.setUndefined(false); + definition.addPortType(portType); + } + + /** + * Called after the {@link PortType} has been created. + *

+ * Default implementation sets the name of the port type to the defined value. + * + * @param portType the WSDL4J PortType + * @throws WSDLException in case of errors + * @see #setPortTypeName(String) + */ + protected void populatePortType(Definition definition, PortType portType) throws WSDLException { + portType.setQName(new QName(definition.getTargetNamespace(), getPortTypeName())); + } + + private void createOperations(Definition definition, PortType portType) throws WSDLException { + Map operations = new HashMap(); + for (Iterator iterator = definition.getMessages().values().iterator(); iterator.hasNext();) { + Message message = (Message) iterator.next(); + String operationName = getOperationName(message); + if (StringUtils.hasText(operationName)) { + List messages = (List) operations.get(operationName); + if (messages == null) { + messages = new ArrayList(); + operations.put(operationName, messages); + } + messages.add(message); + } + } + for (Iterator iterator = operations.keySet().iterator(); iterator.hasNext();) { + String operationName = (String) iterator.next(); + Operation operation = definition.createOperation(); + operation.setName(operationName); + List messages = (List) operations.get(operationName); + for (Iterator messagesIterator = messages.iterator(); messagesIterator.hasNext();) { + Message message = (Message) messagesIterator.next(); + if (isInputMessage(message)) { + Input input = definition.createInput(); + input.setMessage(message); + populateInput(definition, input); + operation.setInput(input); + } + else if (isOutputMessage(message)) { + Output output = definition.createOutput(); + output.setMessage(message); + populateOutput(definition, output); + operation.setOutput(output); + } + else if (isFaultMessage(message)) { + Fault fault = definition.createFault(); + fault.setMessage(message); + populateFault(definition, fault); + operation.addFault(fault); + } + } + operation.setStyle(getOperationType(operation)); + operation.setUndefined(false); + portType.addOperation(operation); + } + } + + /** + * Template method that returns the name of the operation coupled to the given {@link Message}. Subclasses can + * return null to indicate that a message should not be coupled to an operation. + * + * @param message the WSDL4J Message + * @return the operation name; or null + */ + protected abstract String getOperationName(Message message); + + /** + * Indicates whether the given name name should be included as {@link Input} message in the definition. + * + * @param message the message + * @return true if to be included as input; false otherwise + */ + protected abstract boolean isInputMessage(Message message); + + /** + * Called after the {@link javax.wsdl.Input} has been created, but it's added to the operation. Subclasses can + * override this method to define the input name. + *

+ * Default implementation sets the input name to the message name. + * + * @param definition the WSDL4J Definition + * @param input the WSDL4J Input + */ + protected void populateInput(Definition definition, Input input) { + input.setName(input.getMessage().getQName().getLocalPart()); + } + + /** + * Indicates whether the given name name should be included as {@link Output} message in the definition. + * + * @param message the message + * @return true if to be included as output; false otherwise + */ + protected abstract boolean isOutputMessage(Message message); + + /** + * Called after the {@link javax.wsdl.Output} has been created, but it's added to the operation. Subclasses can + * override this method to define the output name. + *

+ * Default implementation sets the output name to the message name. + * + * @param definition the WSDL4J Definition + * @param output the WSDL4J Output + */ + protected void populateOutput(Definition definition, Output output) { + output.setName(output.getMessage().getQName().getLocalPart()); + } + + /** + * Indicates whether the given name name should be included as {@link Fault} message in the definition. + * + * @param message the message + * @return true if to be included as fault; false otherwise + */ + protected abstract boolean isFaultMessage(Message message); + + /** + * Called after the {@link javax.wsdl.Fault} has been created, but it's added to the operation. Subclasses can + * override this method to define the fault name. + *

+ * Default implementation sets the fault name to the message name. + * + * @param definition the WSDL4J Definition + * @param fault the WSDL4J Fault + */ + protected void populateFault(Definition definition, Fault fault) { + fault.setName(fault.getMessage().getQName().getLocalPart()); + } + + /** + * Returns the {@link OperationType} for the given operation. + *

+ * Default implementation returns {@link OperationType#REQUEST_RESPONSE} if both input and output are set; {@link + * OperationType#ONE_WAY} if only input is set, or {@link OperationType#NOTIFICATION} if only output is set. + * + * @param operation the WSDL4J Operation + * @return the operation type for the operation + */ + protected OperationType getOperationType(Operation operation) { + if (operation.getInput() != null && operation.getOutput() != null) { + return OperationType.REQUEST_RESPONSE; + } + else if (operation.getInput() != null && operation.getOutput() == null) { + return OperationType.ONE_WAY; + } + else if (operation.getInput() == null && operation.getOutput() != null) { + return OperationType.NOTIFICATION; + } + else { + return null; + } + } + + +} + + + diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/WsdlVisitor.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/BindingsProvider.java similarity index 62% rename from sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/WsdlVisitor.java rename to sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/BindingsProvider.java index 836da2c2..3a5e704c 100644 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/WsdlVisitor.java +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/BindingsProvider.java @@ -14,12 +14,21 @@ * limitations under the License. */ -package org.springframework.ws.wsdl.wsdl11.visitor; +package org.springframework.ws.wsdl.wsdl11.provider; + +import javax.wsdl.Definition; +import javax.wsdl.WSDLException; /** + * Strategy for adding {@link javax.wsdl.Binding}s to a {@link javax.wsdl.Definition}. + *

+ * Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. + * * @author Arjen Poutsma * @since 1.5.0 */ -public interface WsdlVisitor { +public interface BindingsProvider { + + void addBindings(Definition definition) throws WSDLException; } diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultConcretePartProvider.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultConcretePartProvider.java new file mode 100644 index 00000000..b28ad3d7 --- /dev/null +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultConcretePartProvider.java @@ -0,0 +1,305 @@ +/* + * Copyright 2008 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.wsdl.wsdl11.provider; + +import java.util.Iterator; +import javax.wsdl.Binding; +import javax.wsdl.BindingFault; +import javax.wsdl.BindingInput; +import javax.wsdl.BindingOperation; +import javax.wsdl.BindingOutput; +import javax.wsdl.Definition; +import javax.wsdl.Fault; +import javax.wsdl.Input; +import javax.wsdl.Operation; +import javax.wsdl.OperationType; +import javax.wsdl.Output; +import javax.wsdl.Port; +import javax.wsdl.PortType; +import javax.wsdl.Service; +import javax.wsdl.WSDLException; +import javax.xml.namespace.QName; + +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; + +/** + * Default implementation of the {@link BindingsProvider} and {@link ServicesProvider} interfaces. + *

+ * Creates a binding that matches any present portType, and a service containing + * ports that match the bindings. Lets subclasses populate these through template methods. * + * + * @author Arjen Poutsma + * @since 1.5.0 + */ +public class DefaultConcretePartProvider implements BindingsProvider, ServicesProvider { + + private String bindingSuffix; + + private String serviceName; + + /** Returns the service name. */ + public String getServiceName() { + return serviceName; + } + + /** Sets the service name. */ + public void setServiceName(String serviceName) { + Assert.hasText(serviceName, "'serviceName' must not be null"); + this.serviceName = serviceName; + } + + /** Returns the suffix to append to the port type name to obtain the binding name. */ + public String getBindingSuffix() { + return bindingSuffix; + } + + /** Sets the suffix to append to the port type name to obtain the binding name. */ + public void setBindingSuffix(String bindingSuffix) { + Assert.hasText(bindingSuffix, "'bindingSuffix' must not be null"); + this.bindingSuffix = bindingSuffix; + } + + /** + * Creates a {@link Binding} for each {@link PortType} in the definition, and calls {@link + * #populateBinding(Definition,javax.wsdl.Binding)} with it. Creates a {@link BindingOperation} for each {@link + * Operation} in the port type, a {@link BindingInput} for each {@link Input} in the operation, etc. + *

+ * Calls the various populate methods with the created WSDL4J objects. + * + * @param definition the WSDL4J Definition + * @throws WSDLException in case of errors + * @see #populateBinding(Definition,javax.wsdl.Binding) + * @see #populateBindingOperation(Definition,javax.wsdl.BindingOperation) + * @see #populateBindingInput(Definition,javax.wsdl.BindingInput,javax.wsdl.Input) + * @see #populateBindingOutput(Definition,javax.wsdl.BindingOutput,javax.wsdl.Output) + * @see #populateBindingFault(Definition,javax.wsdl.BindingFault,javax.wsdl.Fault) + */ + public void addBindings(Definition definition) throws WSDLException { + for (Iterator iterator = definition.getPortTypes().values().iterator(); iterator.hasNext();) { + PortType portType = (PortType) iterator.next(); + Binding binding = definition.createBinding(); + binding.setPortType(portType); + populateBinding(definition, binding); + createBindingOperations(definition, binding); + binding.setUndefined(false); + if (binding.getQName() != null) { + definition.addBinding(binding); + } + } + } + + /** + * Called after the {@link Binding} has been created, but before any sub-elements are added. Subclasses can override + * this method to define the binding name, or add extensions to it. + *

+ * Default implementation sets the binding name to the port type name with the {@link #getBindingSuffix() suffix} + * appended to it. + * + * @param definition the WSDL4J Definition + * @param binding the WSDL4J Binding + */ + protected void populateBinding(Definition definition, Binding binding) throws WSDLException { + QName portTypeName = binding.getPortType().getQName(); + if (portTypeName != null) { + binding.setQName( + new QName(portTypeName.getNamespaceURI(), portTypeName.getLocalPart() + getBindingSuffix())); + } + } + + private void createBindingOperations(Definition definition, Binding binding) throws WSDLException { + PortType portType = binding.getPortType(); + for (Iterator operationIterator = portType.getOperations().iterator(); operationIterator.hasNext();) { + Operation operation = (Operation) operationIterator.next(); + BindingOperation bindingOperation = definition.createBindingOperation(); + bindingOperation.setOperation(operation); + populateBindingOperation(definition, bindingOperation); + if (OperationType.REQUEST_RESPONSE.equals(operation.getStyle())) { + createBindingInput(definition, operation, bindingOperation); + createBindingOutput(definition, operation, bindingOperation); + } + else if (OperationType.ONE_WAY.equals(operation.getStyle())) { + createBindingInput(definition, operation, bindingOperation); + } + else if (OperationType.NOTIFICATION.equals(operation.getStyle())) { + createBindingOutput(definition, operation, bindingOperation); + } + else if (OperationType.SOLICIT_RESPONSE.equals(operation.getStyle())) { + createBindingOutput(definition, operation, bindingOperation); + createBindingInput(definition, operation, bindingOperation); + } + for (Iterator faultIterator = operation.getFaults().values().iterator(); faultIterator.hasNext();) { + Fault fault = (Fault) faultIterator.next(); + BindingFault bindingFault = definition.createBindingFault(); + populateBindingFault(definition, bindingFault, fault); + if (StringUtils.hasText(bindingFault.getName())) { + bindingOperation.addBindingFault(bindingFault); + } + } + binding.addBindingOperation(bindingOperation); + } + } + + /** + * Called after the {@link BindingOperation} has been created, but before any sub-elements are added. Subclasses can + * override this method to define the binding name, or add extensions to it. + *

+ * Default implementation sets the name of the binding operation to the name of the operation. + * + * @param definition the WSDL4J Definition + * @param bindingOperation the WSDL4J BindingOperation + * @throws WSDLException in case of errors + */ + protected void populateBindingOperation(Definition definition, BindingOperation bindingOperation) + throws WSDLException { + bindingOperation.setName(bindingOperation.getOperation().getName()); + } + + private void createBindingInput(Definition definition, Operation operation, BindingOperation bindingOperation) + throws WSDLException { + BindingInput bindingInput = definition.createBindingInput(); + populateBindingInput(definition, bindingInput, operation.getInput()); + bindingOperation.setBindingInput(bindingInput); + } + + private void createBindingOutput(Definition definition, Operation operation, BindingOperation bindingOperation) + throws WSDLException { + BindingOutput bindingOutput = definition.createBindingOutput(); + populateBindingOutput(definition, bindingOutput, operation.getOutput()); + bindingOperation.setBindingOutput(bindingOutput); + } + + /** + * Called after the {@link BindingInput} has been created. Subclasses can override this method to define the name, + * or add extensions to it. + *

+ * Default implementation set the name of the binding input to the name of the input. + * + * @param definition the WSDL4J Definition + * @param bindingInput the WSDL4J BindingInput + * @param input the corresponding WSDL4J Input @throws WSDLException in case of errors + */ + protected void populateBindingInput(Definition definition, BindingInput bindingInput, Input input) + throws WSDLException { + bindingInput.setName(input.getName()); + } + + /** + * Called after the {@link BindingOutput} has been created. Subclasses can override this method to define the name, + * or add extensions to it. + *

+ * Default implementation sets the name of the binding output to the name of the output. + * + * @param definition the WSDL4J Definition + * @param bindingOutput the WSDL4J BindingOutput + * @param output the corresponding WSDL4J Output @throws WSDLException in case of errors + */ + protected void populateBindingOutput(Definition definition, BindingOutput bindingOutput, Output output) + throws WSDLException { + bindingOutput.setName(output.getName()); + } + + /** + * Called after the {@link BindingFault} has been created. Subclasses can implement this method to define the name, + * or add extensions to it. + *

+ * Default implementation set the name of the binding fault to the name of the fault. + * + * @param bindingFault the WSDL4J BindingFault + * @param fault the corresponding WSDL4J Fault @throws WSDLException in case of errors + */ + protected void populateBindingFault(Definition definition, BindingFault bindingFault, Fault fault) + throws WSDLException { + bindingFault.setName(fault.getName()); + } + + /** + * Creates a single {@link Service} if not present, and calls {@link #populateService(Definition, Service)} with it. + * Creates a corresponding {@link Port} for each {@link Binding}, which is passed to {@link + * #populatePort(javax.wsdl.Definition,javax.wsdl.Port)}. + * + * @param definition the WSDL4J Definition + * @throws WSDLException in case of errors + */ + public void addServices(Definition definition) throws WSDLException { + Assert.notNull(getServiceName(), "'serviceName' is required"); + Service service; + if (definition.getServices().isEmpty()) { + service = definition.createService(); + } + else { + service = (Service) definition.getServices().values().iterator().next(); + } + populateService(definition, service); + createPorts(definition, service); + if (service.getQName() != null) { + definition.addService(service); + } + } + + /** + * Called after the {@link Service} has been created, but before any sub-elements are added. Subclasses can + * implement this method to define the service name, or add extensions to it. + *

+ * Default implementation sets the name to the {@link #setServiceName(String) serviceName} property. + * + * @param service the WSDL4J Service + * @throws WSDLException in case of errors + */ + protected void populateService(Definition definition, Service service) throws WSDLException { + if (StringUtils.hasText(definition.getTargetNamespace()) && StringUtils.hasText(getServiceName())) { + QName serviceName = new QName(definition.getTargetNamespace(), getServiceName()); + service.setQName(serviceName); + } + } + + private void createPorts(Definition definition, Service service) throws WSDLException { + for (Iterator iterator = definition.getBindings().values().iterator(); iterator.hasNext();) { + Binding binding = (Binding) iterator.next(); + Port port = null; + for (Iterator iterator1 = service.getPorts().values().iterator(); iterator1.hasNext();) { + Port existingPort = (Port) iterator1.next(); + if (binding.equals(existingPort.getBinding())) { + port = existingPort; + } + } + if (port == null) { + port = definition.createPort(); + port.setBinding(binding); + } + populatePort(definition, port); + if (StringUtils.hasText(port.getName())) { + service.addPort(port); + } + } + } + + /** + * Called after the {@link Port} has been created, but before any sub-elements are added. Subclasses can implement + * this method to define the port name, or add extensions to it. + *

+ * Default implementation sets the port name to the binding name. + * + * @param definition the WSDL4J Definition + * @param port the WSDL4J Port + * @throws WSDLException in case of errors + */ + protected void populatePort(Definition definition, Port port) throws WSDLException { + port.setName(port.getBinding().getQName().getLocalPart()); + } + +} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProvider.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProvider.java new file mode 100644 index 00000000..59528fd5 --- /dev/null +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProvider.java @@ -0,0 +1,124 @@ +/* + * Copyright 2008 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.wsdl.wsdl11.provider; + +import java.util.Iterator; +import javax.wsdl.Definition; +import javax.wsdl.Message; +import javax.wsdl.Part; +import javax.wsdl.Types; +import javax.wsdl.WSDLException; +import javax.wsdl.extensions.ExtensibilityElement; +import javax.wsdl.extensions.schema.Schema; +import javax.xml.namespace.QName; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import org.springframework.util.Assert; + +/** + * Default implementation of the {@link MessagesProvider}. + *

+ * Simply adds all elements contained in the schema(s) as messages. + * + * @author Arjen Poutsma + * @since 1.5.0 + */ +public class DefaultMessagesProvider implements MessagesProvider { + + public void addMessages(Definition definition) throws WSDLException { + Types types = definition.getTypes(); + Assert.notNull(types, "No types element present in definition"); + for (Iterator iterator = types.getExtensibilityElements().iterator(); iterator.hasNext();) { + ExtensibilityElement extensibilityElement = (ExtensibilityElement) iterator.next(); + if (extensibilityElement instanceof Schema) { + Schema schema = (Schema) extensibilityElement; + if (schema.getElement() != null) { + createMessages(definition, schema.getElement()); + } + } + } + } + + private void createMessages(Definition definition, Element schemaElement) throws WSDLException { + String schemaTargetNamespace = schemaElement.getAttribute("targetNamespace"); + Assert.hasText("No targetNamespace defined on schema"); + NodeList children = schemaElement.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node child = children.item(i); + if (child.getNodeType() == Node.ELEMENT_NODE) { + Element childElement = (Element) child; + if (isMessageElement(childElement)) { + QName elementName = new QName(schemaTargetNamespace, childElement.getAttribute("name")); + Message message = definition.createMessage(); + populateMessage(definition, message, elementName); + Part part = definition.createPart(); + populatePart(definition, part, elementName); + message.addPart(part); + message.setUndefined(false); + definition.addMessage(message); + } + } + } + } + + /** + * Indicates whether the given element should be includes as {@link Message} in the definition. + *

+ * Default implementation checks whether the element has the XML Schema namespace, and if it has the local name + * "element". + * + * @param element the element elligable for being a message + * @return true if to be included as message; false otherwise + */ + protected boolean isMessageElement(Element element) { + return "element".equals(element.getLocalName()) && + "http://www.w3.org/2001/XMLSchema".equals(element.getNamespaceURI()); + } + + /** + * Called after the {@link Message} has been created. + *

+ * Default implementation sets the name of the message to the element name. + * + * @param definition the WSDL4J Definition + * @param message the WSDL4J Message + * @param elementName the element name + * @throws WSDLException in case of errors + */ + protected void populateMessage(Definition definition, Message message, QName elementName) throws WSDLException { + message.setQName(new QName(definition.getTargetNamespace(), elementName.getLocalPart())); + } + + /** + * Called after the {@link Part} has been created. + *

+ * Default implementation sets the element name of the part. + * + * @param definition the WSDL4J Definition + * @param part the WSDL4J Part + * @param elementName the elementName @throws WSDLException in case of errors + * @see Part#setElementName(javax.xml.namespace.QName) + */ + protected void populatePart(Definition definition, Part part, QName elementName) throws WSDLException { + part.setElementName(elementName); + part.setName(elementName.getLocalPart()); + } + +} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultServiceProvider.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultServiceProvider.java deleted file mode 100644 index c7fe9b42..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultServiceProvider.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2008 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.wsdl.wsdl11.provider; - -import java.util.Iterator; -import javax.wsdl.Binding; -import javax.wsdl.Definition; -import javax.wsdl.Port; -import javax.wsdl.Service; -import javax.wsdl.WSDLException; -import javax.xml.namespace.QName; - -import org.springframework.xml.namespace.QNameUtils; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public class DefaultServiceProvider implements ServiceProvider { - - private QName serviceName; - - /** - * Returns the service name. - */ - public QName getServiceName() { - return serviceName; - } - - /** - * Sets the service name. - */ - public void setServiceName(String serviceName) { - this.serviceName = QNameUtils.parseQNameString(serviceName); - } - - public void addService(Definition definition) throws WSDLException { - Service service = definition.createService(); - populateService(service); - createPorts(definition, service); - definition.addService(service); - } - - /** - * Called after the {@link javax.wsdl.Service} has been created, but before any sub-elements are added. Subclasses - * can implement this method to define the service name, or add extensions to it. - *

- * Default implementation sets the name to the {@link #setServiceName(String) serviceName} property. - * - * @param service the WSDL4J Service - * @throws WSDLException in case of errors - */ - protected void populateService(Service service) throws WSDLException { - service.setQName(getServiceName()); - } - - private void createPorts(Definition definition, Service service) throws WSDLException { - for (Iterator iterator = definition.getBindings().values().iterator(); iterator.hasNext();) { - Binding binding = (Binding) iterator.next(); - Port port = definition.createPort(); - port.setBinding(binding); - populatePort(port, binding); - service.addPort(port); - } - } - - /** - * Called after the {@link Port} has been created, but before any sub-elements are added. Subclasses can implement - * this method to define the port name, or add extensions to it. - *

- * Default implementation sets the port name to the binding name. - * - * @param port the WSDL4J Port - * @param binding the corresponding WSDL4J Binding - * @throws WSDLException in case of errors - */ - protected void populatePort(Port port, Binding binding) throws WSDLException { - port.setName(binding.getQName().getLocalPart()); - } - -} diff --git a/sandbox/src/main/java/org/springframework/xml/xsd/XsdSchemaCollection.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ImportsProvider.java similarity index 62% rename from sandbox/src/main/java/org/springframework/xml/xsd/XsdSchemaCollection.java rename to sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ImportsProvider.java index 3fefe614..9680efda 100644 --- a/sandbox/src/main/java/org/springframework/xml/xsd/XsdSchemaCollection.java +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ImportsProvider.java @@ -14,20 +14,21 @@ * limitations under the License. */ -package org.springframework.xml.xsd; +package org.springframework.ws.wsdl.wsdl11.provider; + +import javax.wsdl.Definition; +import javax.wsdl.WSDLException; /** - * Represents an abstraction for a collection of XSD schemas. + * Strategy for adding {@link javax.wsdl.Import}s to a {@link javax.wsdl.Definition}. + *

+ * Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. * * @author Arjen Poutsma * @since 1.5.0 */ -public interface XsdSchemaCollection { +public interface ImportsProvider { + + void addImports(Definition definition) throws WSDLException; - /** - * Returns all schema's contained in this collection. - * - * @return the schema's contained in this collection - */ - XsdSchema[] getXsdSchemas(); } diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProvider.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProvider.java new file mode 100644 index 00000000..d30c43c1 --- /dev/null +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProvider.java @@ -0,0 +1,109 @@ +/* + * Copyright 2008 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.wsdl.wsdl11.provider; + +import javax.wsdl.Definition; +import javax.wsdl.Types; +import javax.wsdl.WSDLException; +import javax.wsdl.extensions.schema.Schema; +import javax.xml.namespace.QName; +import javax.xml.transform.TransformerException; +import javax.xml.transform.dom.DOMResult; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import org.springframework.util.Assert; +import org.springframework.ws.wsdl.WsdlDefinitionException; +import org.springframework.xml.transform.TransformerObjectSupport; +import org.springframework.xml.xsd.XsdSchema; +import org.springframework.xml.xsd.XsdSchemaCollection; + +/** + * Implementation of {@link TypesProvider} that inlines a {@link XsdSchema} or {@link XsdSchemaCollection} into the + * WSDL. + * + * @author Arjen Poutsma + * @since 1.5.0 + */ +public class InliningXsdSchemaTypesProvider extends TransformerObjectSupport implements TypesProvider { + + /** The prefix used to register the schema namespace in the WSDL. */ + public static final String SCHEMA_PREFIX = "sch"; + + private XsdSchemaCollection schemaCollection; + + /** + * Sets the single XSD schema to inline. Either this property, or {@link #setSchemaCollection(XsdSchemaCollection) + * schemaCollection} must be set. + */ + public void setSchema(final XsdSchema schema) { + this.schemaCollection = new XsdSchemaCollection() { + + public XsdSchema[] getXsdSchemas() { + return new XsdSchema[]{schema}; + } + }; + } + + /** Returns the XSD schema collection to inline. */ + public XsdSchemaCollection getSchemaCollection() { + return schemaCollection; + } + + /** + * Sets the XSD schema collection to inline. Either this property, or {@link #setSchema(XsdSchema) schema} must be + * set. + */ + public void setSchemaCollection(XsdSchemaCollection schemaCollection) { + this.schemaCollection = schemaCollection; + } + + public void addTypes(Definition definition) throws WSDLException { + Assert.notNull(getSchemaCollection(), "setting 'schema' or 'schemaCollection' is required"); + Types types = definition.createTypes(); + XsdSchema[] schemas = schemaCollection.getXsdSchemas(); + for (int i = 0; i < schemas.length; i++) { + if (schemas.length == 1) { + definition.addNamespace(SCHEMA_PREFIX, schemas[i].getTargetNamespace()); + } + else { + String prefix = SCHEMA_PREFIX + i; + definition.addNamespace(prefix, schemas[i].getTargetNamespace()); + } + Element schemaElement = getSchemaElement(schemas[i]); + Schema schema = (Schema) definition.getExtensionRegistry() + .createExtension(Types.class, new QName("http://www.w3.org/2001/XMLSchema", "schema")); + types.addExtensibilityElement(schema); + schema.setElement(schemaElement); + } + definition.setTypes(types); + } + + private Element getSchemaElement(XsdSchema schema) { + try { + DOMResult result = new DOMResult(); + transform(schema.getSource(), result); + Document schemaDocument = (Document) result.getNode(); + return schemaDocument.getDocumentElement(); + } + catch (TransformerException e) { + throw new WsdlDefinitionException("Could not transform schema source to Document"); + } + } + +} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/ImportVisitor.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/MessagesProvider.java similarity index 61% rename from sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/ImportVisitor.java rename to sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/MessagesProvider.java index 2ac5d7fe..9ede46a0 100644 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/ImportVisitor.java +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/MessagesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2007 the original author or authors. + * Copyright 2008 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. @@ -14,19 +14,21 @@ * limitations under the License. */ -package org.springframework.ws.wsdl.wsdl11.visitor; +package org.springframework.ws.wsdl.wsdl11.provider; -import javax.wsdl.Import; +import javax.wsdl.Definition; import javax.wsdl.WSDLException; /** + * Strategy for adding {@link javax.wsdl.Message}s to a {@link javax.wsdl.Definition}. + *

+ * Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. + * * @author Arjen Poutsma * @since 1.5.0 */ -public interface ImportVisitor { +public interface MessagesProvider { - void startImport(Import anImport) throws WSDLException; - - void endImport(Import anImport) throws WSDLException; + void addMessages(Definition definition) throws WSDLException; } diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/PortTypesProvider.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/PortTypesProvider.java new file mode 100644 index 00000000..1ec99c71 --- /dev/null +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/PortTypesProvider.java @@ -0,0 +1,34 @@ +/* + * Copyright 2008 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.wsdl.wsdl11.provider; + +import javax.wsdl.Definition; +import javax.wsdl.WSDLException; + +/** + * Strategy for adding {@link javax.wsdl.PortType}s to a {@link javax.wsdl.Definition}. + *

+ * Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. + * + * @author Arjen Poutsma + * @since 1.5.0 + */ +public interface PortTypesProvider { + + void addPortTypes(Definition definition) throws WSDLException; + +} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ServicesProvider.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ServicesProvider.java new file mode 100644 index 00000000..552caa40 --- /dev/null +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/ServicesProvider.java @@ -0,0 +1,34 @@ +/* + * Copyright 2008 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.wsdl.wsdl11.provider; + +import javax.wsdl.Definition; +import javax.wsdl.WSDLException; + +/** + * Strategy for adding {@link javax.wsdl.Service}s to a {@link javax.wsdl.Definition}. + *

+ * Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. + * + * @author Arjen Poutsma + * @since 1.5.0 + */ +public interface ServicesProvider { + + void addServices(Definition definition) throws WSDLException; + +} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11Provider.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11Provider.java new file mode 100644 index 00000000..7219fd4f --- /dev/null +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11Provider.java @@ -0,0 +1,345 @@ +/* + * Copyright 2008 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.wsdl.wsdl11.provider; + +import java.util.Iterator; +import java.util.Properties; +import javax.wsdl.Binding; +import javax.wsdl.BindingFault; +import javax.wsdl.BindingInput; +import javax.wsdl.BindingOperation; +import javax.wsdl.BindingOutput; +import javax.wsdl.Definition; +import javax.wsdl.Fault; +import javax.wsdl.Input; +import javax.wsdl.Output; +import javax.wsdl.Port; +import javax.wsdl.WSDLException; +import javax.wsdl.extensions.ExtensibilityElement; +import javax.wsdl.extensions.ExtensionRegistry; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap.SOAPBinding; +import javax.wsdl.extensions.soap.SOAPBody; +import javax.wsdl.extensions.soap.SOAPFault; +import javax.wsdl.extensions.soap.SOAPOperation; +import javax.xml.namespace.QName; + +import org.springframework.util.Assert; + +/** + * Implementation of the {@link BindingsProvider} and {@link ServicesProvider} interfaces that are SOAP 1.1 specific. + *

+ * By setting the {@link #setSoapActions(java.util.Properties) soapActions} property, the SOAP Actions defined in the + * resulting WSDL can be set. Additionaly, the transport uri can be changed from the default HTTP transport by using the + * {@link #setTransportUri(String) transportUri} property. + * + * @author Arjen Poutsma + * @since 1.5.0 + */ +public class Soap11Provider extends DefaultConcretePartProvider { + + /** The default transport URI, which indicates an HTTP transport. */ + public static final String DEFAULT_TRANSPORT_URI = "http://schemas.xmlsoap.org/soap/http"; + + /** The prefix of the WSDL SOAP 1.1 namespace. */ + public static final String SOAP_11_NAMESPACE_PREFIX = "soap"; + + /** The WSDL SOAP 1.1 namespace. */ + public static final String SOAP_11_NAMESPACE_URI = "http://schemas.xmlsoap.org/wsdl/soap/"; + + private String transportUri = DEFAULT_TRANSPORT_URI; + + private Properties soapActions = new Properties(); + + private String locationUri; + + /** + * Constructs a new version of the {@link Soap11Provider}. + *

+ * Sets the {@link #setBindingSuffix(String) binding suffix} to Soap11. + */ + public Soap11Provider() { + setBindingSuffix("Soap11"); + } + + /** + * Returns the SOAP Actions for this binding. Keys are {@link BindingOperation#getName() binding operation names}; + * values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}. + * + * @return the soap actions + */ + public Properties getSoapActions() { + return soapActions; + } + + /** + * Sets the SOAP Actions for this binding. Keys are {@link BindingOperation#getName() binding operation names}; + * values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}. + * + * @param soapActions the soap + */ + public void setSoapActions(Properties soapActions) { + Assert.notNull(soapActions, "'soapActions' must not be null"); + this.soapActions = soapActions; + } + + /** + * Returns the value used for the binding transport attribute value. Defaults to {@link #DEFAULT_TRANSPORT_URI}. + * + * @return the binding transport value + */ + public String getTransportUri() { + return transportUri; + } + + /** + * Sets the value used for the binding transport attribute value. Defaults to {@link #DEFAULT_TRANSPORT_URI}. + * + * @param transportUri the binding transport value + */ + public void setTransportUri(String transportUri) { + Assert.notNull(transportUri, "'transportUri' must not be null"); + this.transportUri = transportUri; + } + + /** Returns the value used for the SOAP Address location attribute value. */ + public String getLocationUri() { + return locationUri; + } + + /** Sets the value used for the SOAP Address location attribute value. */ + public void setLocationUri(String locationUri) { + this.locationUri = locationUri; + } + + /** + * Called after the {@link Binding} has been created, but before any sub-elements are added. Subclasses can override + * this method to define the binding name, or add extensions to it. + *

+ * Default implementation calls {@link DefaultConcretePartProvider#populateBinding(Definition, Binding)}, adds the + * SOAP 1.1 namespace, creates a {@link SOAPBinding}, and calls {@link #populateSoapBinding(SOAPBinding, Binding)} + * sets the binding name to the port type name with the {@link #getBindingSuffix() suffix} appended to it. + * + * @param definition the WSDL4J Definition + * @param binding the WSDL4J Binding + */ + protected void populateBinding(Definition definition, Binding binding) throws WSDLException { + definition.addNamespace(SOAP_11_NAMESPACE_PREFIX, SOAP_11_NAMESPACE_URI); + super.populateBinding(definition, binding); + SOAPBinding soapBinding = (SOAPBinding) createSoapExtension(definition, Binding.class, "binding"); + populateSoapBinding(soapBinding, binding); + binding.addExtensibilityElement(soapBinding); + } + + /** + * Called after the {@link SOAPBinding} has been created. + *

+ * Default implementation sets the binding style to "document", and set the transport URI to the {@link + * #setTransportUri(String) transportUri} property value. Subclasses can override this behavior. + * + * @param soapBinding the WSDL4J SOAPBinding + * @throws WSDLException in case of errors + * @see SOAPBinding#setStyle(String) + * @see SOAPBinding#setTransportURI(String) + * @see #setTransportUri(String) + * @see #DEFAULT_TRANSPORT_URI + */ + protected void populateSoapBinding(SOAPBinding soapBinding, Binding binding) throws WSDLException { + soapBinding.setStyle("document"); + soapBinding.setTransportURI(getTransportUri()); + } + + /** + * Called after the {@link BindingFault} has been created. Subclasses can override this method to define the name, + * or add extensions to it. + *

+ * Default implementation calls {@link DefaultConcretePartProvider#populateBindingFault(Definition, BindingFault, + * Fault)}, creates a {@link SOAPFault}, and calls {@link #populateSoapFault(BindingFault, SOAPFault)}. + * + * @param definition the WSDL4J Definition + * @param bindingFault the WSDL4J BindingFault + * @param fault the corresponding WSDL4J Fault @throws WSDLException in case of errors + */ + protected void populateBindingFault(Definition definition, BindingFault bindingFault, Fault fault) + throws WSDLException { + super.populateBindingFault(definition, bindingFault, fault); + SOAPFault soapFault = (SOAPFault) createSoapExtension(definition, BindingFault.class, "fault"); + populateSoapFault(bindingFault, soapFault); + bindingFault.addExtensibilityElement(soapFault); + } + + /** + * Called after the {@link SOAPFault} has been created. + *

+ * Default implementation sets the use style to "literal", and sets the name equal to the binding + * fault. Subclasses can override this behavior. + * + * @param bindingFault the WSDL4J BindingFault + * @param soapFault the WSDL4J SOAPFault + * @throws WSDLException in case of errors + * @see SOAPFault#setUse(String) + */ + protected void populateSoapFault(BindingFault bindingFault, SOAPFault soapFault) throws WSDLException { + soapFault.setName(bindingFault.getName()); + soapFault.setUse("literal"); + } + + /** + * Called after the {@link BindingInput} has been created. Subclasses can implement this method to define the name, + * or add extensions to it. + *

+ * Default implementation calls {@link DefaultConcretePartProvider#populateBindingInput(Definition, + * javax.wsdl.BindingInput, javax.wsdl.Input)}, creates a {@link SOAPBody}, and calls {@link + * #populateSoapBody(SOAPBody)}. + * + * @param definition the WSDL4J Definition + * @param bindingInput the WSDL4J BindingInput + * @param input the corresponding WSDL4J Input @throws WSDLException in case of errors + */ + protected void populateBindingInput(Definition definition, BindingInput bindingInput, Input input) + throws WSDLException { + super.populateBindingInput(definition, bindingInput, input); + SOAPBody soapBody = (SOAPBody) createSoapExtension(definition, BindingInput.class, "body"); + populateSoapBody(soapBody); + bindingInput.addExtensibilityElement(soapBody); + } + + /** + * Called after the {@link SOAPBody} has been created. + *

+ * Default implementation sets the use style to "literal". Subclasses can override this behavior. + * + * @param soapBody the WSDL4J SOAPBody + * @throws WSDLException in case of errors + * @see SOAPBody#setUse(String) + */ + protected void populateSoapBody(SOAPBody soapBody) throws WSDLException { + soapBody.setUse("literal"); + } + + /** + * Called after the {@link BindingOperation} has been created, but before any sub-elements are added. Subclasses can + * implement this method to define the binding name, or add extensions to it. + *

+ * Default implementation calls {@link DefaultConcretePartProvider#populateBindingOperation(Definition, + * BindingOperation)}, creates a {@link SOAPOperation}, and calls {@link #populateSoapOperation} sets the name of + * the binding operation to the name of the operation. + * + * @param definition the WSDL4J Definition + * @param bindingOperation the WSDL4J BindingOperation + * @throws WSDLException in case of errors + */ + protected void populateBindingOperation(Definition definition, BindingOperation bindingOperation) + throws WSDLException { + super.populateBindingOperation(definition, bindingOperation); + SOAPOperation soapOperation = + (SOAPOperation) createSoapExtension(definition, BindingOperation.class, "operation"); + populateSoapOperation(soapOperation, bindingOperation); + bindingOperation.addExtensibilityElement(soapOperation); + } + + /** + * Called after the {@link SOAPOperation} has been created. + *

+ * Default implementation sets SOAPAction to the corresponding {@link + * #setSoapActions(java.util.Properties) soapActions} property, and defaults to "". + * + * @param soapOperation the WSDL4J SOAPOperation + * @param bindingOperation the WSDL4J BindingOperation + * @throws WSDLException in case of errors + * @see SOAPOperation#setSoapActionURI(String) + * @see #setSoapActions(java.util.Properties) + */ + protected void populateSoapOperation(SOAPOperation soapOperation, BindingOperation bindingOperation) + throws WSDLException { + String bindingOperationName = bindingOperation.getName(); + String soapAction = getSoapActions().getProperty(bindingOperationName, ""); + soapOperation.setSoapActionURI(soapAction); + } + + /** + * Called after the {@link BindingInput} has been created. Subclasses can implement this method to define the name, + * or add extensions to it. + *

+ * Default implementation calls {@link DefaultConcretePartProvider#populateBindingOutput(Definition, BindingOutput, + * Output)}, creates a {@link SOAPBody}, and calls {@link #populateSoapBody(SOAPBody)}. + * + * @param definition the WSDL4J Definition + * @param bindingOutput the WSDL4J BindingOutput + * @param output the corresponding WSDL4J Output @throws WSDLException in case of errors + */ + protected void populateBindingOutput(Definition definition, BindingOutput bindingOutput, Output output) + throws WSDLException { + super.populateBindingOutput(definition, bindingOutput, output); + SOAPBody soapBody = (SOAPBody) createSoapExtension(definition, BindingOutput.class, "body"); + populateSoapBody(soapBody); + bindingOutput.addExtensibilityElement(soapBody); + } + + /** + * Called after the {@link Port} has been created, but before any sub-elements are added. Subclasses can implement + * this method to define the port name, or add extensions to it. + *

+ * Default implementation calls {@link DefaultConcretePartProvider#populatePort(javax.wsdl.Definition,javax.wsdl.Port)}, + * creates a {@link SOAPAddress}, and calls {@link #populateSoapAddress(SOAPAddress)}. + * + * @param port the WSDL4J Port + * @throws WSDLException in case of errors + */ + protected void populatePort(Definition definition, Port port) throws WSDLException { + for (Iterator iterator = port.getBinding().getExtensibilityElements().iterator(); iterator.hasNext();) { + if (iterator.next() instanceof SOAPBinding) { + // this is a SOAP 1.1 binding, create a SOAP Address for it + super.populatePort(definition, port); + SOAPAddress soapAddress = (SOAPAddress) createSoapExtension(definition, Port.class, "address"); + populateSoapAddress(soapAddress); + port.addExtensibilityElement(soapAddress); + return; + } + } + } + + /** + * Called after the {@link SOAPAddress} has been created. Default implementation sets the location URI to the value + * set on this builder. Subclasses can override this behavior. + * + * @param soapAddress the WSDL4J SOAPAddress + * @throws WSDLException in case of errors + * @see SOAPAddress#setLocationURI(String) + * @see #setLocationUri(String) + */ + protected void populateSoapAddress(SOAPAddress soapAddress) throws WSDLException { + soapAddress.setLocationURI(getLocationUri()); + } + + /** + * Creates a SOAP extensibility element. + * + * @param definition the WSDL4J Definition + * @param parentType a class object indicating where in the WSDL definition this extension will exist + * @param localName the local name of the extensibility element + * @return the extensibility element + * @throws WSDLException in case of errors + * @see ExtensionRegistry#createExtension(Class, QName) + */ + private ExtensibilityElement createSoapExtension(Definition definition, Class parentType, String localName) + throws WSDLException { + return definition.getExtensionRegistry() + .createExtension(parentType, new QName(SOAP_11_NAMESPACE_URI, localName)); + } + +} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12Provider.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12Provider.java new file mode 100644 index 00000000..13ab2c4a --- /dev/null +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12Provider.java @@ -0,0 +1,348 @@ +/* + * Copyright 2008 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.wsdl.wsdl11.provider; + +import java.util.Iterator; +import java.util.Properties; +import javax.wsdl.Binding; +import javax.wsdl.BindingFault; +import javax.wsdl.BindingInput; +import javax.wsdl.BindingOperation; +import javax.wsdl.BindingOutput; +import javax.wsdl.Definition; +import javax.wsdl.Fault; +import javax.wsdl.Input; +import javax.wsdl.Output; +import javax.wsdl.Port; +import javax.wsdl.WSDLException; +import javax.wsdl.extensions.ExtensibilityElement; +import javax.wsdl.extensions.soap12.SOAP12Address; +import javax.wsdl.extensions.soap12.SOAP12Binding; +import javax.wsdl.extensions.soap12.SOAP12Body; +import javax.wsdl.extensions.soap12.SOAP12Fault; +import javax.wsdl.extensions.soap12.SOAP12Operation; +import javax.xml.namespace.QName; + +import org.springframework.util.Assert; + +/** + * Implementation of the {@link BindingsProvider} and {@link ServicesProvider} interfaces that are SOAP 1.2 specific. + *

+ * By setting the {@link #setSoapActions(java.util.Properties) soapActions} property, the SOAP Actions defined in the + * resulting WSDL can be set. Additionaly, the transport uri can be changed from the default HTTP transport by using the + * {@link #setTransportUri(String) transportUri} property. + * + * @author Arjen Poutsma + * @since 1.5.0 + */ +public class Soap12Provider extends DefaultConcretePartProvider { + + /** The default transport URI, which indicates an HTTP transport. */ + public static final String DEFAULT_TRANSPORT_URI = "http://schemas.xmlsoap.org/soap/http"; + + /** The prefix of the WSDL SOAP 1.2 namespace. */ + public static final String SOAP_12_NAMESPACE_PREFIX = "soap12"; + + /** The WSDL SOAP 1.1 namespace. */ + public static final String SOAP_12_NAMESPACE_URI = "http://schemas.xmlsoap.org/wsdl/soap12/"; + + private String transportUri = DEFAULT_TRANSPORT_URI; + + private Properties soapActions = new Properties(); + + private String locationUri; + + /** + * Constructs a new version of the {@link Soap12Provider}. + *

+ * Sets the {@link #setBindingSuffix(String) binding suffix} to Soap12. + */ + public Soap12Provider() { + setBindingSuffix("Soap12"); + } + + /** + * Returns the SOAP Actions for this binding. Keys are {@link javax.wsdl.BindingOperation#getName() binding + * operation names}; values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action + * URIs}. + * + * @return the soap actions + */ + public Properties getSoapActions() { + return soapActions; + } + + /** + * Sets the SOAP Actions for this binding. Keys are {@link javax.wsdl.BindingOperation#getName() binding operation + * names}; values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}. + * + * @param soapActions the soap + */ + public void setSoapActions(Properties soapActions) { + Assert.notNull(soapActions, "'soapActions' must not be null"); + this.soapActions = soapActions; + } + + /** + * Returns the value used for the binding transport attribute value. Defaults to {@link #DEFAULT_TRANSPORT_URI}. + * + * @return the binding transport value + */ + public String getTransportUri() { + return transportUri; + } + + /** + * Sets the value used for the binding transport attribute value. Defaults to {@link #DEFAULT_TRANSPORT_URI}. + * + * @param transportUri the binding transport value + */ + public void setTransportUri(String transportUri) { + Assert.notNull(transportUri, "'transportUri' must not be null"); + this.transportUri = transportUri; + } + + /** Returns the value used for the SOAP Address location attribute value. */ + public String getLocationUri() { + return locationUri; + } + + /** Sets the value used for the SOAP Address location attribute value. */ + public void setLocationUri(String locationUri) { + this.locationUri = locationUri; + } + + /** + * Called after the {@link javax.wsdl.Binding} has been created, but before any sub-elements are added. Subclasses + * can override this method to define the binding name, or add extensions to it. + *

+ * Default implementation calls {@link DefaultConcretePartProvider#populateBinding(javax.wsdl.Definition, + * javax.wsdl.Binding)}, adds the SOAP 1.1 namespace, creates a {@link javax.wsdl.extensions.soap.SOAPBinding}, and + * calls {@link #populateSoapBinding(javax.wsdl.extensions.soap12.SOAP12Binding, javax.wsdl.Binding)} sets the + * binding name to the port type name with the {@link #getBindingSuffix() suffix} appended to it. + * + * @param definition the WSDL4J Definition + * @param binding the WSDL4J Binding + */ + protected void populateBinding(Definition definition, Binding binding) throws WSDLException { + definition.addNamespace(SOAP_12_NAMESPACE_PREFIX, SOAP_12_NAMESPACE_URI); + super.populateBinding(definition, binding); + SOAP12Binding soapBinding = (SOAP12Binding) createSoapExtension(definition, Binding.class, "binding"); + populateSoapBinding(soapBinding, binding); + binding.addExtensibilityElement(soapBinding); + } + + /** + * Called after the {@link javax.wsdl.extensions.soap.SOAPBinding} has been created. + *

+ * Default implementation sets the binding style to "document", and set the transport URI to the {@link + * #setTransportUri(String) transportUri} property value. Subclasses can override this behavior. + * + * @param soapBinding the WSDL4J SOAPBinding + * @throws javax.wsdl.WSDLException in case of errors + * @see javax.wsdl.extensions.soap.SOAPBinding#setStyle(String) + * @see javax.wsdl.extensions.soap.SOAPBinding#setTransportURI(String) + * @see #setTransportUri(String) + * @see #DEFAULT_TRANSPORT_URI + */ + protected void populateSoapBinding(SOAP12Binding soapBinding, Binding binding) throws WSDLException { + soapBinding.setStyle("document"); + soapBinding.setTransportURI(getTransportUri()); + } + + /** + * Called after the {@link javax.wsdl.BindingFault} has been created. Subclasses can override this method to define + * the name, or add extensions to it. + *

+ * Default implementation calls {@link DefaultConcretePartProvider#populateBindingFault(javax.wsdl.Definition, + * javax.wsdl.BindingFault, javax.wsdl.Fault)}, creates a {@link javax.wsdl.extensions.soap.SOAPFault}, and calls + * {@link #populateSoapFault(javax.wsdl.BindingFault, javax.wsdl.extensions.soap12.SOAP12Fault)}. + * + * @param definition the WSDL4J Definition + * @param bindingFault the WSDL4J BindingFault + * @param fault the corresponding WSDL4J Fault @throws WSDLException in case of errors + */ + protected void populateBindingFault(Definition definition, BindingFault bindingFault, Fault fault) + throws WSDLException { + super.populateBindingFault(definition, bindingFault, fault); + SOAP12Fault soapFault = (SOAP12Fault) createSoapExtension(definition, BindingFault.class, "fault"); + populateSoapFault(bindingFault, soapFault); + bindingFault.addExtensibilityElement(soapFault); + } + + /** + * Called after the {@link javax.wsdl.extensions.soap.SOAPFault} has been created. + *

+ * Default implementation sets the use style to "literal", and sets the name equal to the binding + * fault. Subclasses can override this behavior. + * + * @param bindingFault the WSDL4J BindingFault + * @param soapFault the WSDL4J SOAPFault + * @throws javax.wsdl.WSDLException in case of errors + * @see javax.wsdl.extensions.soap.SOAPFault#setUse(String) + */ + protected void populateSoapFault(BindingFault bindingFault, SOAP12Fault soapFault) throws WSDLException { + soapFault.setName(bindingFault.getName()); + soapFault.setUse("literal"); + } + + /** + * Called after the {@link javax.wsdl.BindingInput} has been created. Subclasses can implement this method to define + * the name, or add extensions to it. + *

+ * Default implementation calls {@link DefaultConcretePartProvider#populateBindingInput(javax.wsdl.Definition, + * javax.wsdl.BindingInput, javax.wsdl.Input)}, creates a {@link javax.wsdl.extensions.soap.SOAPBody}, and calls + * {@link #populateSoapBody(javax.wsdl.extensions.soap12.SOAP12Body)}. 2 + * + * @param definition the WSDL4J Definition + * @param bindingInput the WSDL4J BindingInput + * @param input the corresponding WSDL4J Input @throws WSDLException in case of errors + */ + protected void populateBindingInput(Definition definition, BindingInput bindingInput, Input input) + throws WSDLException { + super.populateBindingInput(definition, bindingInput, input); + SOAP12Body soapBody = (SOAP12Body) createSoapExtension(definition, BindingInput.class, "body"); + populateSoapBody(soapBody); + bindingInput.addExtensibilityElement(soapBody); + } + + /** + * Called after the {@link javax.wsdl.extensions.soap.SOAPBody} has been created. + *

+ * Default implementation sets the use style to "literal". Subclasses can override this behavior. + * + * @param soapBody the WSDL4J SOAPBody + * @throws javax.wsdl.WSDLException in case of errors + * @see javax.wsdl.extensions.soap.SOAPBody#setUse(String) + */ + protected void populateSoapBody(SOAP12Body soapBody) throws WSDLException { + soapBody.setUse("literal"); + } + + /** + * Called after the {@link javax.wsdl.BindingOperation} has been created, but before any sub-elements are added. + * Subclasses can implement this method to define the binding name, or add extensions to it. + *

+ * Default implementation calls {@link DefaultConcretePartProvider#populateBindingOperation(javax.wsdl.Definition, + * javax.wsdl.BindingOperation)}, creates a {@link javax.wsdl.extensions.soap.SOAPOperation}, and calls {@link + * #populateSoapOperation} sets the name of the binding operation to the name of the operation. + * + * @param definition the WSDL4J Definition + * @param bindingOperation the WSDL4J BindingOperation + * @throws javax.wsdl.WSDLException in case of errors + */ + protected void populateBindingOperation(Definition definition, BindingOperation bindingOperation) + throws WSDLException { + super.populateBindingOperation(definition, bindingOperation); + SOAP12Operation soapOperation = + (SOAP12Operation) createSoapExtension(definition, BindingOperation.class, "operation"); + populateSoapOperation(soapOperation, bindingOperation); + bindingOperation.addExtensibilityElement(soapOperation); + } + + /** + * Called after the {@link javax.wsdl.extensions.soap.SOAPOperation} has been created. + *

+ * Default implementation sets SOAPAction to the corresponding {@link + * #setSoapActions(java.util.Properties) soapActions} property, and defaults to "". + * + * @param soapOperation the WSDL4J SOAPOperation + * @param bindingOperation the WSDL4J BindingOperation + * @throws javax.wsdl.WSDLException in case of errors + * @see javax.wsdl.extensions.soap.SOAPOperation#setSoapActionURI(String) + * @see #setSoapActions(java.util.Properties) + */ + protected void populateSoapOperation(SOAP12Operation soapOperation, BindingOperation bindingOperation) + throws WSDLException { + String bindingOperationName = bindingOperation.getName(); + String soapAction = getSoapActions().getProperty(bindingOperationName, ""); + soapOperation.setSoapActionURI(soapAction); + } + + /** + * Called after the {@link javax.wsdl.BindingInput} has been created. Subclasses can implement this method to define + * the name, or add extensions to it. + *

+ * Default implementation calls {@link DefaultConcretePartProvider#populateBindingOutput(javax.wsdl.Definition, + * javax.wsdl.BindingOutput, javax.wsdl.Output)}, creates a {@link javax.wsdl.extensions.soap.SOAPBody}, and calls + * {@link #populateSoapBody(javax.wsdl.extensions.soap12.SOAP12Body)}. + * + * @param definition the WSDL4J Definition + * @param bindingOutput the WSDL4J BindingOutput + * @param output the corresponding WSDL4J Output @throws WSDLException in case of errors + */ + protected void populateBindingOutput(Definition definition, BindingOutput bindingOutput, Output output) + throws WSDLException { + super.populateBindingOutput(definition, bindingOutput, output); + SOAP12Body soapBody = (SOAP12Body) createSoapExtension(definition, BindingOutput.class, "body"); + populateSoapBody(soapBody); + bindingOutput.addExtensibilityElement(soapBody); + } + + /** + * Called after the {@link javax.wsdl.Port} has been created, but before any sub-elements are added. Subclasses can + * implement this method to define the port name, or add extensions to it. + *

+ * Default implementation calls {@link DefaultConcretePartProvider#populatePort(javax.wsdl.Definition,javax.wsdl.Port)}, + * creates a {@link javax.wsdl.extensions.soap.SOAPAddress}, and calls {@link #populateSoapAddress(SOAP12Address)}. + * + * @param port the WSDL4J Port + * @throws WSDLException in case of errors + */ + protected void populatePort(Definition definition, Port port) throws WSDLException { + for (Iterator iterator = port.getBinding().getExtensibilityElements().iterator(); iterator.hasNext();) { + if (iterator.next() instanceof SOAP12Binding) { + // this is a SOAP 1.2 binding, create a SOAP Address for it + super.populatePort(definition, port); + SOAP12Address soapAddress = (SOAP12Address) createSoapExtension(definition, Port.class, "address"); + populateSoapAddress(soapAddress); + port.addExtensibilityElement(soapAddress); + return; + } + } + } + + /** + * Called after the {@link SOAP12Address} has been created. Default implementation sets the location URI to the + * value set on this builder. Subclasses can override this behavior. + * + * @param soapAddress the WSDL4J SOAPAddress + * @throws WSDLException in case of errors + * @see SOAP12Address#setLocationURI(String) + * @see #setLocationUri(String) + */ + protected void populateSoapAddress(SOAP12Address soapAddress) throws WSDLException { + soapAddress.setLocationURI(getLocationUri()); + } + + /** + * Creates a SOAP extensibility element. + * + * @param definition the WSDL4J Definition + * @param parentType a class object indicating where in the WSDL definition this extension will exist + * @param localName the local name of the extensibility element + * @return the extensibility element + * @throws WSDLException in case of errors + * @see javax.wsdl.extensions.ExtensionRegistry#createExtension(Class, QName) + */ + private ExtensibilityElement createSoapExtension(Definition definition, Class parentType, String localName) + throws WSDLException { + return definition.getExtensionRegistry() + .createExtension(parentType, new QName(SOAP_12_NAMESPACE_URI, localName)); + } + +} \ No newline at end of file diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProvider.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProvider.java new file mode 100644 index 00000000..2b76f463 --- /dev/null +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProvider.java @@ -0,0 +1,112 @@ +/* + * Copyright 2008 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.wsdl.wsdl11.provider; + +import java.util.Properties; +import javax.wsdl.Definition; +import javax.wsdl.WSDLException; + +/** + * Implementation of the {@link BindingsProvider} and {@link ServicesProvider} interfaces that supports SOAP 1.1 and + * SOAP 1.2. Delegates to {@link Soap11Provider} and {@link Soap12Provider}. + *

+ * By setting the {@link #setSoapActions(java.util.Properties) soapActions} property, the SOAP Actions defined in the + * resulting WSDL can be set. Additionaly, the transport uri can be changed from the default HTTP transport by using the + * {@link #setTransportUri(String) transportUri} property. + *

+ * The {@link #setCreateSoap11Binding(boolean) createSoap11} and {@link #setCreateSoap12Binding(boolean) createSoap12} + * properties indicate whether a SOAP 1.1 or SOAP 1.2 binding should be created. These properties default to + * true and false respectively. + * + * @author Arjen Poutsma + * @since 1.5.0 + */ +public class SoapProvider implements BindingsProvider, ServicesProvider { + + private final Soap11Provider soap11BindingProvider = new Soap11Provider(); + + private final Soap12Provider soap12BindingProvider = new Soap12Provider(); + + private boolean createSoap11Binding = true; + + private boolean createSoap12Binding = false; + + /** + * Indicates whether a SOAP 1.1 binding should be created. + *

+ * Defaults to true. + */ + public void setCreateSoap11Binding(boolean createSoap11Binding) { + this.createSoap11Binding = createSoap11Binding; + } + + /** + * Indicates whether a SOAP 1.2 binding should be created. + *

+ * Defaults to false. + */ + public void setCreateSoap12Binding(boolean createSoap12Binding) { + this.createSoap12Binding = createSoap12Binding; + } + + /** + * Sets the SOAP Actions for this binding. Keys are {@link javax.wsdl.BindingOperation#getName() binding operation + * names}; values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}. + * + * @param soapActions the soap + */ + public void setSoapActions(Properties soapActions) { + soap11BindingProvider.setSoapActions(soapActions); + soap12BindingProvider.setSoapActions(soapActions); + } + + /** Sets the value used for the binding transport attribute value. Defaults to HTTP. */ + public void setTransportUri(String transportUri) { + soap11BindingProvider.setTransportUri(transportUri); + soap12BindingProvider.setTransportUri(transportUri); + } + + /** Sets the value used for the SOAP Address location attribute value. */ + public void setLocationUri(String locationUri) { + soap11BindingProvider.setLocationUri(locationUri); + soap12BindingProvider.setLocationUri(locationUri); + } + + /** Sets the service name. */ + public void setServiceName(String serviceName) { + soap11BindingProvider.setServiceName(serviceName); + soap12BindingProvider.setServiceName(serviceName); + } + + public void addBindings(Definition definition) throws WSDLException { + if (createSoap11Binding) { + soap11BindingProvider.addBindings(definition); + } + if (createSoap12Binding) { + soap12BindingProvider.addBindings(definition); + } + } + + public void addServices(Definition definition) throws WSDLException { + if (createSoap11Binding) { + soap11BindingProvider.addServices(definition); + } + if (createSoap12Binding) { + soap12BindingProvider.addServices(definition); + } + } +} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProvider.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProvider.java new file mode 100644 index 00000000..279e72cf --- /dev/null +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProvider.java @@ -0,0 +1,156 @@ +/* + * Copyright 2008 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.wsdl.wsdl11.provider; + +import javax.wsdl.Message; + +/** + * @author Arjen Poutsma + * @since 1.5.0 + */ +public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider { + + /** The default suffix used to detect request elements in the schema. */ + public static final String DEFAULT_REQUEST_SUFFIX = "Request"; + + /** The default suffix used to detect response elements in the schema. */ + public static final String DEFAULT_RESPONSE_SUFFIX = "Response"; + + /** The default suffix used to detect fault elements in the schema. */ + public static final String DEFAULT_FAULT_SUFFIX = "Fault"; + + private String requestSuffix = DEFAULT_REQUEST_SUFFIX; + + private String responseSuffix = DEFAULT_RESPONSE_SUFFIX; + + private String faultSuffix = DEFAULT_FAULT_SUFFIX; + + /** + * Returns the suffix used to detect request elements in the schema. + * + * @see #DEFAULT_REQUEST_SUFFIX + */ + public String getRequestSuffix() { + return requestSuffix; + } + + /** + * Sets the suffix used to detect request elements in the schema. + * + * @see #DEFAULT_REQUEST_SUFFIX + */ + public void setRequestSuffix(String requestSuffix) { + this.requestSuffix = requestSuffix; + } + + /** + * Returns the suffix used to detect response elements in the schema. + * + * @see #DEFAULT_RESPONSE_SUFFIX + */ + public String getResponseSuffix() { + return responseSuffix; + } + + /** + * Sets the suffix used to detect response elements in the schema. + * + * @see #DEFAULT_RESPONSE_SUFFIX + */ + public void setResponseSuffix(String responseSuffix) { + this.responseSuffix = responseSuffix; + } + + /** + * Returns the suffix used to detect fault elements in the schema. + * + * @see #DEFAULT_FAULT_SUFFIX + */ + public String getFaultSuffix() { + return faultSuffix; + } + + /** + * Sets the suffix used to detect fault elements in the schema. + * + * @see #DEFAULT_FAULT_SUFFIX + */ + public void setFaultSuffix(String faultSuffix) { + this.faultSuffix = faultSuffix; + } + + protected String getOperationName(Message message) { + String messageName = getMessageName(message); + if (messageName != null) { + if (messageName.endsWith(getRequestSuffix())) { + return messageName.substring(0, messageName.length() - getRequestSuffix().length()); + } + else if (messageName.endsWith(getResponseSuffix())) { + return messageName.substring(0, messageName.length() - getResponseSuffix().length()); + } + else if (messageName.endsWith(getFaultSuffix())) { + return messageName.substring(0, messageName.length() - getFaultSuffix().length()); + } + } + return null; + } + + /** + * Indicates whether the given name name should be included as {@link javax.wsdl.Input} message in the definition. + *

+ * This implementation checks whether the message name ends with the {@link #setRequestSuffix(String) + * requestSuffix}. + * + * @param message the message + * @return true if to be included as input; false otherwise + */ + protected boolean isInputMessage(Message message) { + String messageName = getMessageName(message); + return messageName != null && messageName.endsWith(getRequestSuffix()); + } + + /** + * Indicates whether the given name name should be included as {@link javax.wsdl.Output} message in the definition. + *

+ * This implementation checks whether the message name ends with the {@link #setResponseSuffix(String) + * responseSuffix}. + * + * @param message the message + * @return true if to be included as output; false otherwise + */ + protected boolean isOutputMessage(Message message) { + String messageName = getMessageName(message); + return messageName != null && messageName.endsWith(getResponseSuffix()); + } + + /** + * Indicates whether the given name name should be included as {@link javax.wsdl.Fault} message in the definition. + *

+ * This implementation checks whether the message name ends with the {@link #setFaultSuffix(String) faultSuffix}. + * + * @param message the message + * @return true if to be included as fault; false otherwise + */ + protected boolean isFaultMessage(Message message) { + String messageName = getMessageName(message); + return messageName != null && messageName.endsWith(getFaultSuffix()); + } + + private String getMessageName(Message message) { + return message.getQName().getLocalPart(); + } +} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/DefinitionVisitor.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/TypesProvider.java similarity index 64% rename from sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/DefinitionVisitor.java rename to sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/TypesProvider.java index ace54677..67d3c6b5 100644 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/DefinitionVisitor.java +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/TypesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2007 the original author or authors. + * Copyright 2008 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. @@ -14,19 +14,21 @@ * limitations under the License. */ -package org.springframework.ws.wsdl.wsdl11.visitor; +package org.springframework.ws.wsdl.wsdl11.provider; import javax.wsdl.Definition; import javax.wsdl.WSDLException; /** + * Strategy for adding {@link javax.wsdl.Types} to a {@link javax.wsdl.Definition}. + *

+ * Used by {@link org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition}. + * * @author Arjen Poutsma * @since 1.5.0 */ -public interface DefinitionVisitor { +public interface TypesProvider { - void startDefinition(Definition definition) throws WSDLException; - - void endDefinition(Definition definition) throws WSDLException; + void addTypes(Definition definition) throws WSDLException; } diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/package.html b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/package.html new file mode 100644 index 00000000..3e60e98c --- /dev/null +++ b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/package.html @@ -0,0 +1,5 @@ + + +Provides a contribution strategy for WSDL definitions. + + diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/AbstractSoapWsdl11Definition.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/AbstractSoapWsdl11Definition.java deleted file mode 100644 index 4ac5228b..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/AbstractSoapWsdl11Definition.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright 2008 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.wsdl.wsdl11.soap; - -import java.util.Iterator; -import java.util.List; -import java.util.Properties; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; -import org.springframework.ws.wsdl.wsdl11.DomWsdl11Definition; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public abstract class AbstractSoapWsdl11Definition extends DomWsdl11Definition { - - /** The default transport URI, which indicates an HTTP transport. */ - public static final String DEFAULT_TRANSPORT_URI = "http://schemas.xmlsoap.org/soap/http"; - - private String transportUri = DEFAULT_TRANSPORT_URI; - - private Properties soapActions = new Properties(); - - private String serviceName; - - private String locationUri; - - /** - * Sets the value used for the binding transport attribute value. Defaults to {@link #DEFAULT_TRANSPORT_URI}. - * - * @param transportUri the binding transport value - */ - public void setTransportUri(String transportUri) { - Assert.notNull(transportUri, "'transportUri' must not be null"); - this.transportUri = transportUri; - } - - /** - * Sets the SOAP Actions for this binding. Keys are {@link javax.wsdl.BindingOperation#getName() binding operation - * names}; values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}. - * - * @param soapActions the soap - * @return the soap actions - */ - public void setSoapActions(Properties soapActions) { - Assert.notNull(soapActions, "'soapActions' must not be null"); - this.soapActions = soapActions; - } - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - - public void setLocationUri(String locationUri) { - this.locationUri = locationUri; - } - - public void afterPropertiesSet() throws Exception { - super.afterPropertiesSet(); - Assert.notNull(serviceName, "'serviceName' is required"); - Assert.notNull(locationUri, "'locationUri' is required"); - } - - protected void declareNamespaces(Element definitions) { - super.declareNamespaces(definitions); - declareNamespace(definitions, getSoapNamespacePrefix(), getSoapNamespaceUri()); - } - - protected void addBindings(Document document, Element definitions) { - List portTypes = getWsdlChildElements(definitions, "portType"); - for (Iterator iterator = portTypes.iterator(); iterator.hasNext();) { - Element portType = (Element) iterator.next(); - addSoapBinding(document, definitions, portType); - } - } - - private void addSoapBinding(Document document, Element definitions, Element portType) { - Element binding = createWsdlElement(document, "binding"); - definitions.appendChild(binding); - String portTypeName = portType.getAttribute("name"); - Assert.hasText(portTypeName, " lacks required name attribute"); - binding.setAttribute("name", portTypeName + getBindingSuffix()); - binding.setAttribute("type", TARGET_NAMESPACE_PREFIX + ":" + portTypeName); - Element soapBinding = createSoapElement(document, "binding"); - binding.appendChild(soapBinding); - soapBinding.setAttribute("style", "document"); - soapBinding.setAttribute("transport", transportUri); - - List operations = getWsdlChildElements(portType, "operation"); - for (Iterator iterator = operations.iterator(); iterator.hasNext();) { - Element operation = (Element) iterator.next(); - addSoapOperation(document, binding, operation); - } - } - - private void addSoapOperation(Document document, Element binding, Element operation) { - Element bindingOperation = createWsdlElement(document, "operation"); - binding.appendChild(bindingOperation); - String operationName = operation.getAttribute("name"); - Assert.hasText(operationName, " lacks required name attribute"); - bindingOperation.setAttribute("name", operationName); - Element soapOperation = createSoapElement(document, "operation"); - bindingOperation.appendChild(soapOperation); - String soapAction = soapActions.getProperty(operationName, ""); - soapOperation.setAttribute("soapAction", soapAction); - - Element input = getWsdlChildElement(operation, "input"); - if (input != null) { - createBindingInputOutput(document, input, bindingOperation, "input"); - } - Element output = getWsdlChildElement(operation, "output"); - if (output != null) { - createBindingInputOutput(document, output, bindingOperation, "output"); - } - List faults = getWsdlChildElements(operation, "fault"); - for (Iterator iterator = faults.iterator(); iterator.hasNext();) { - Element fault = (Element) iterator.next(); - createBindingFault(document, bindingOperation, fault); - } - } - - private void createBindingInputOutput(Document document, - Element inputOutput, - Element bindingOperation, - String localName) { - Element bindingInputOutput = createWsdlElement(document, localName); - bindingOperation.appendChild(bindingInputOutput); - String inputOutputName = inputOutput.getAttribute("name"); - if (StringUtils.hasLength(inputOutputName)) { - bindingInputOutput.setAttribute("name", inputOutputName); - } - Element soapBody = createSoapElement(document, "body"); - bindingInputOutput.appendChild(soapBody); - soapBody.setAttribute("use", "literal"); - } - - private void createBindingFault(Document document, Element bindingOperation, Element fault) { - Element bindingFault = createWsdlElement(document, "fault"); - bindingOperation.appendChild(bindingFault); - String faultName = fault.getAttribute("name"); - Assert.hasText(faultName, " lacks required name attribute"); - bindingFault.setAttribute("name", faultName); - Element soapBody = createSoapElement(document, "body"); - bindingFault.appendChild(soapBody); - soapBody.setAttribute("use", "literal"); - } - - protected void addServices(Document document, Element definitions) { - List bindings = getWsdlChildElements(definitions, "binding"); - if (!bindings.isEmpty()) { - Element service = getWsdlChildElement(definitions, "service"); - if (service == null) { - service = createWsdlElement(document, "service"); - } - definitions.appendChild(service); - service.setAttribute("name", serviceName); - for (Iterator iterator = bindings.iterator(); iterator.hasNext();) { - Element binding = (Element) iterator.next(); - Element soapBinding = getChildElement(binding, getSoapNamespaceUri(), "binding"); - if (soapBinding != null) { - addSoapPort(document, service, binding); - } - } - } - } - - private void addSoapPort(Document document, Element service, Element binding) { - Element port = createWsdlElement(document, "port"); - service.appendChild(port); - String bindingName = binding.getAttribute("name"); - Assert.hasText(serviceName, " lacks required name attribute"); - port.setAttribute("name", bindingName); - port.setAttribute("binding", TARGET_NAMESPACE_PREFIX + ":" + bindingName); - Element soapAddress = createElement(document, getSoapNamespacePrefix(), getSoapNamespacePrefix(), "address"); - port.appendChild(soapAddress); - soapAddress.setAttribute("location", locationUri); - } - - protected Element createSoapElement(Document document, String localName) { - return createElement(document, getSoapNamespacePrefix(), getSoapNamespaceUri(), localName); - } - - protected abstract String getSoapNamespaceUri(); - - protected abstract String getSoapNamespacePrefix(); - - protected abstract String getBindingSuffix(); - - -} \ No newline at end of file diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/Soap11Wsdl11Definition.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/Soap11Wsdl11Definition.java deleted file mode 100644 index eb5f9353..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/Soap11Wsdl11Definition.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2008 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.wsdl.wsdl11.soap; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public class Soap11Wsdl11Definition extends AbstractSoapWsdl11Definition { - - public static final String SOAP_11_NAMESPACE_URI = "http://schemas.xmlsoap.org/wsdl/soap/"; - - public static final String SOAP_11_NAMESPACE_PREFIX = "soap"; - - protected String getSoapNamespaceUri() { - return SOAP_11_NAMESPACE_URI; - } - - protected String getSoapNamespacePrefix() { - return SOAP_11_NAMESPACE_PREFIX; - } - - protected String getBindingSuffix() { - return "Soap11"; - } -} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/Soap12Wsdl11Definition.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/Soap12Wsdl11Definition.java deleted file mode 100644 index a09e57b3..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/Soap12Wsdl11Definition.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2008 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.wsdl.wsdl11.soap; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public class Soap12Wsdl11Definition extends AbstractSoapWsdl11Definition { - - public static final String SOAP_12_NAMESPACE_URI = "http://schemas.xmlsoap.org/wsdl/soap12/"; - - public static final String SOAP_12_NAMESPACE_PREFIX = "soap12"; - - protected String getSoapNamespaceUri() { - return SOAP_12_NAMESPACE_URI; - } - - protected String getSoapNamespacePrefix() { - return SOAP_12_NAMESPACE_PREFIX; - } - - protected String getBindingSuffix() { - return "Soap12"; - } -} \ No newline at end of file diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/SoapWsdl11Definition.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/SoapWsdl11Definition.java deleted file mode 100644 index 01e5e322..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/soap/SoapWsdl11Definition.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2008 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.wsdl.wsdl11.soap; - -import java.util.Properties; - -import org.w3c.dom.Element; -import org.w3c.dom.Document; - -import org.springframework.ws.wsdl.wsdl11.DomWsdl11Definition; -import org.springframework.util.Assert; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public class SoapWsdl11Definition extends DomWsdl11Definition { - - private Soap11Wsdl11Definition soap11BindingDefinition = new Soap11Wsdl11Definition(); - - private Soap12Wsdl11Definition soap12BindingDefinition = new Soap12Wsdl11Definition(); - - private boolean createSoap11Binding = true; - - private boolean createSoap12Binding = false; - - public void setCreateSoap11Binding(boolean createSoap11Binding) { - this.createSoap11Binding = createSoap11Binding; - } - - public void setCreateSoap12Binding(boolean createSoap12Binding) { - this.createSoap12Binding = createSoap12Binding; - } - - public void setTargetNamespace(String targetNamespace) { - super.setTargetNamespace(targetNamespace); - soap11BindingDefinition.setTargetNamespace(targetNamespace); - soap12BindingDefinition.setTargetNamespace(targetNamespace); - } - - /** - * Sets the value used for the binding transport attribute value. Defaults to the HTTP transport. - * - * @param transportUri the binding transport value - */ - public void setTransportUri(String transportUri) { - Assert.notNull(transportUri, "'transportUri' must not be null"); - soap11BindingDefinition.setTransportUri(transportUri); - soap12BindingDefinition.setTransportUri(transportUri); - } - - /** - * Sets the SOAP Actions for this binding. Keys are {@link javax.wsdl.BindingOperation#getName() binding operation - * names}; values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}. - * - * @param soapActions the soap - * @return the soap actions - */ - public void setSoapActions(Properties soapActions) { - Assert.notNull(soapActions, "'soapActions' must not be null"); - soap11BindingDefinition.setSoapActions(soapActions); - soap12BindingDefinition.setSoapActions(soapActions); - } - - public void setServiceName(String serviceName) { - Assert.notNull(serviceName, "'serviceName' must not be null"); - soap11BindingDefinition.setServiceName(serviceName); - soap12BindingDefinition.setServiceName(serviceName); - } - - public void setLocationUri(String locationUri) { - Assert.notNull(locationUri, "'locationUri' must not be null"); - soap11BindingDefinition.setLocationUri(locationUri); - soap12BindingDefinition.setLocationUri(locationUri); - } - - public void afterPropertiesSet() throws Exception { - soap11BindingDefinition.afterPropertiesSet(); - soap12BindingDefinition.afterPropertiesSet(); - super.afterPropertiesSet(); - } - - protected void declareNamespaces(Element definitions) { - super.declareNamespaces(definitions); - if (createSoap11Binding) { - soap11BindingDefinition.declareNamespaces(definitions); - } - if (createSoap12Binding) { - soap12BindingDefinition.declareNamespaces(definitions); - } - } - - protected void addBindings(Document document, Element definitions) { - if (createSoap11Binding) { - soap11BindingDefinition.addBindings(document, definitions); - } - if (createSoap12Binding) { - soap12BindingDefinition.addBindings(document, definitions); - } - } - - protected void addServices(Document document, Element definitions) { - if (createSoap11Binding) { - soap11BindingDefinition.addServices(document, definitions); - } - if (createSoap12Binding) { - soap12BindingDefinition.addServices(document, definitions); - } - } -} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/BindingVisitor.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/BindingVisitor.java deleted file mode 100644 index 1f6abe1e..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/BindingVisitor.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - */ - -package org.springframework.ws.wsdl.wsdl11.visitor; - -import javax.wsdl.Binding; -import javax.wsdl.BindingFault; -import javax.wsdl.BindingInput; -import javax.wsdl.BindingOperation; -import javax.wsdl.BindingOutput; -import javax.wsdl.WSDLException; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public interface BindingVisitor { - - void startBinding(Binding binding) throws WSDLException; - - void startBindingOperation(BindingOperation operation) throws WSDLException; - - void bindingInput(BindingInput input) throws WSDLException; - - void bindingOutput(BindingOutput output) throws WSDLException; - - void bindingFault(BindingFault fault) throws WSDLException; - - void endBindingOperation(BindingOperation operation) throws WSDLException; - - void endBinding(Binding binding) throws WSDLException; - -} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/DefaultBindingVisitor.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/DefaultBindingVisitor.java deleted file mode 100644 index 4ba18a1d..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/DefaultBindingVisitor.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright 2006 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.wsdl.wsdl11.visitor; - -import javax.wsdl.Binding; -import javax.wsdl.BindingFault; -import javax.wsdl.BindingInput; -import javax.wsdl.BindingOperation; -import javax.wsdl.BindingOutput; -import javax.wsdl.Definition; -import javax.wsdl.Fault; -import javax.wsdl.Input; -import javax.wsdl.Operation; -import javax.wsdl.Output; -import javax.wsdl.PortType; -import javax.wsdl.WSDLException; -import javax.xml.namespace.QName; - -/** - * Abstract base class for Wsdl11DefinitionBuilder implementations that use WSDL4J and contain a concrete - * part. Creates a binding that matches any present portType. Lets subclasses populate these - * through template methods. - * - * @author Arjen Poutsma - * @since 1.5.0 - */ -public class DefaultBindingVisitor implements PortTypeVisitor, DefinitionVisitor { - - /** The suffix used to create a binding name from a port type name. */ - public static final String DEFAULT_BINDING_SUFFIX = "Binding"; - - private Binding binding; - - private BindingOperation bindingOperation; - - private Definition definition; - - private String bindingSuffix = DEFAULT_BINDING_SUFFIX; - - public String getBindingSuffix() { - return bindingSuffix; - } - - public void setBindingSuffix(String bindingSuffix) { - this.bindingSuffix = bindingSuffix; - } - - public void startDefinition(Definition definition) throws WSDLException { - this.definition = definition; - } - - public void startPortType(PortType portType) throws WSDLException { - binding = definition.createBinding(); - binding.setPortType(portType); - populateBinding(binding, portType); - binding.setUndefined(false); - } - - /** - * Called after the {@link Binding} has been created, but before any sub-elements are added. Subclasses can - * implement this method to define the binding name, or add extensions to it. - *

- * Default implementation sets the binding name to the port type name with the suffix {@link Binding} appended to - * it. - * - * @param binding the WSDL4J Binding - * @param portType the corresponding PortType - * @throws WSDLException in case of errors - */ - protected void populateBinding(Binding binding, PortType portType) throws WSDLException { - QName portTypeName = portType.getQName(); - if (portTypeName != null) { - binding.setQName(new QName(portTypeName.getNamespaceURI(), portTypeName.getLocalPart() + - getBindingSuffix())); - } - } - - public void endPortType(PortType portType) throws WSDLException { - definition.addBinding(binding); - } - - public void startOperation(Operation operation) throws WSDLException { - bindingOperation = definition.createBindingOperation(); - bindingOperation.setOperation(operation); - populateBindingOperation(bindingOperation, operation); - } - - /** - * Called after the {@link BindingOperation} has been created, but before any sub-elements are added. Subclasses can - * implement this method to define the binding name, or add extensions to it. - *

- * Default implementation sets the name of the binding operation to the name of the operation. - * - * @param bindingOperation the WSDL4J BindingOperation - * @param operation the corresponding WSDL4J Operation - * @throws WSDLException in case of errors - */ - protected void populateBindingOperation(BindingOperation bindingOperation, Operation operation) - throws WSDLException { - bindingOperation.setName(operation.getName()); - } - - public void input(Input input) throws WSDLException { - BindingInput bindingInput = definition.createBindingInput(); - populateBindingInput(bindingInput, bindingOperation.getOperation().getInput()); - bindingOperation.setBindingInput(bindingInput); - } - - /** - * Called after the {@link BindingInput} has been created. Subclasses can implement this method to define the name, - * or add extensions to it. - *

- * Default implementation set the name of the binding input to the name of the input. - * - * @param bindingInput the WSDL4J BindingInput - * @param input the corresponding WSDL4J Input - * @throws WSDLException in case of errors - */ - protected void populateBindingInput(BindingInput bindingInput, Input input) throws WSDLException { - bindingInput.setName(input.getName()); - } - - public void output(Output output) throws WSDLException { - BindingOutput bindingOutput = definition.createBindingOutput(); - populateBindingOutput(bindingOutput, bindingOperation.getOperation().getOutput()); - bindingOperation.setBindingOutput(bindingOutput); - } - - /** - * Called after the {@link BindingOutput} has been created. Subclasses can implement this method to define the name, - * or add extensions to it. - *

- * Default implementation set the name of the binding output to the name of the output. - * - * @param bindingOutput the WSDL4J BindingOutput - * @param output the corresponding WSDL4J Output - * @throws WSDLException in case of errors - */ - protected void populateBindingOutput(BindingOutput bindingOutput, Output output) throws WSDLException { - bindingOutput.setName(output.getName()); - } - - public void fault(Fault fault) throws WSDLException { - BindingFault bindingFault = definition.createBindingFault(); - populateBindingFault(bindingFault, fault); - bindingOperation.addBindingFault(bindingFault); - } - - /** - * Called after the {@link BindingFault} has been created. Subclasses can implement this method to define the name, - * or add extensions to it. - *

- * Default implementation set the name of the binding fault to the name of the fault. - * - * @param bindingFault the WSDL4J BindingFault - * @param fault the corresponding WSDL4J Fault - * @throws WSDLException in case of errors - */ - protected void populateBindingFault(BindingFault bindingFault, Fault fault) throws WSDLException { - bindingFault.setName(fault.getName()); - } - - public void endOperation(Operation operation) throws WSDLException { - binding.addBindingOperation(bindingOperation); - bindingOperation = null; - } - - public void endDefinition(Definition definition) throws WSDLException { - this.definition = null; - } - -} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/DefaultServiceVisitor.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/DefaultServiceVisitor.java deleted file mode 100644 index d6a5286f..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/DefaultServiceVisitor.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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. - */ - -package org.springframework.ws.wsdl.wsdl11.visitor; - -import javax.wsdl.Binding; -import javax.wsdl.BindingFault; -import javax.wsdl.BindingInput; -import javax.wsdl.BindingOperation; -import javax.wsdl.BindingOutput; -import javax.wsdl.Definition; -import javax.wsdl.Fault; -import javax.wsdl.Input; -import javax.wsdl.Operation; -import javax.wsdl.Output; -import javax.wsdl.Port; -import javax.wsdl.PortType; -import javax.wsdl.Service; -import javax.wsdl.WSDLException; -import javax.xml.namespace.QName; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public class DefaultServiceVisitor implements PortTypeVisitor, BindingVisitor, DefinitionVisitor { - - private Definition definition; - - /** The suffix used to create a binding name from a port type name. */ - private static final String PORT_SUFFIX = "Port"; - - /** The suffix used to create a service name from a port type name. */ - private static final String SERVICE_SUFFIX = "Service"; - - private Service service; - - public void startDefinition(Definition definition) throws WSDLException { - this.definition = definition; - this.service = this.definition.createService(); - } - - public void startPortType(PortType portType) throws WSDLException { - } - - public void startOperation(Operation operation) throws WSDLException { - } - - public void input(Input input) throws WSDLException { - } - - public void output(Output output) throws WSDLException { - } - - public void fault(Fault fault) throws WSDLException { - } - - public void endOperation(Operation operation) throws WSDLException { - } - - public void endPortType(PortType portType) throws WSDLException { - QName portTypeName = portType.getQName(); - QName serviceName = new QName(portTypeName.getNamespaceURI(), portTypeName.getLocalPart() + SERVICE_SUFFIX); - service.setQName(serviceName); - } - - public void startBinding(Binding binding) throws WSDLException { - Port port = definition.createPort(); - port.setBinding(binding); - populatePort(port, binding); - service.addPort(port); - } - - - /** - * Called after the {@link Port} has been created, but before any sub-elements are added. Subclasses can implement - * this method to define the port name, or add extensions to it. - *

- * Default implementation sets the port name to the port type name with the suffix {@link Port} appended to it. - * - * @param port the WSDL4J Port - * @param binding the corresponding WSDL4J Binding - * @throws WSDLException in case of errors - */ - protected void populatePort(Port port, Binding binding) throws WSDLException { - if (binding.getPortType() != null && binding.getPortType().getQName() != null) { - port.setName(binding.getPortType().getQName().getLocalPart() + PORT_SUFFIX); - } - } - - public void startBindingOperation(BindingOperation operation) throws WSDLException { - } - - public void bindingInput(BindingInput input) throws WSDLException { - } - - public void bindingOutput(BindingOutput output) throws WSDLException { - } - - public void bindingFault(BindingFault fault) throws WSDLException { - } - - public void endBindingOperation(BindingOperation operation) throws WSDLException { - } - - public void endBinding(Binding binding) throws WSDLException { - } - - public void endDefinition(Definition definition) throws WSDLException { - this.definition.addService(service); - this.definition = null; - this.service = null; - } -} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/MessageVisitor.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/MessageVisitor.java deleted file mode 100644 index b8c83ada..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/MessageVisitor.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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. - */ - -package org.springframework.ws.wsdl.wsdl11.visitor; - -import javax.wsdl.Message; -import javax.wsdl.Part; -import javax.wsdl.WSDLException; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public interface MessageVisitor { - - void startMessage(Message message) throws WSDLException; - - void part(Part part) throws WSDLException; - - void endMessage(Message message) throws WSDLException; - -} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/PortTypeVisitor.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/PortTypeVisitor.java deleted file mode 100644 index 596e9662..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/PortTypeVisitor.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - */ - -package org.springframework.ws.wsdl.wsdl11.visitor; - -import javax.wsdl.Fault; -import javax.wsdl.Input; -import javax.wsdl.Operation; -import javax.wsdl.Output; -import javax.wsdl.PortType; -import javax.wsdl.WSDLException; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public interface PortTypeVisitor { - - void startPortType(PortType portType) throws WSDLException; - - void startOperation(Operation operation) throws WSDLException; - - void input(Input input) throws WSDLException; - - void output(Output output) throws WSDLException; - - void fault(Fault fault) throws WSDLException; - - void endOperation(Operation operation) throws WSDLException; - - void endPortType(PortType portType) throws WSDLException; - -} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/ServiceVisitor.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/ServiceVisitor.java deleted file mode 100644 index 4faab0d4..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/ServiceVisitor.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ - -package org.springframework.ws.wsdl.wsdl11.visitor; - -import javax.wsdl.Service; -import javax.wsdl.WSDLException; -import javax.wsdl.Port; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public interface ServiceVisitor { - - void startService(Service service) throws WSDLException; - - void startPort(Port port) throws WSDLException; - - void endPort(Port port) throws WSDLException; - - void endService(Service service) throws WSDLException; - -} diff --git a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/TypesVisitor.java b/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/TypesVisitor.java deleted file mode 100644 index a41b2080..00000000 --- a/sandbox/src/main/java/org/springframework/ws/wsdl/wsdl11/visitor/TypesVisitor.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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. - */ - -package org.springframework.ws.wsdl.wsdl11.visitor; - -import javax.wsdl.Types; -import javax.wsdl.WSDLException; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public interface TypesVisitor extends DefinitionVisitor { - - void startTypes(Types types) throws WSDLException; - - void endTypes(Types types) throws WSDLException; - -} diff --git a/sandbox/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollection.java b/sandbox/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollection.java deleted file mode 100644 index 3c222610..00000000 --- a/sandbox/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollection.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2008 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.xml.xsd.commons; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import javax.xml.transform.Source; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.ws.commons.schema.XmlSchema; -import org.apache.ws.commons.schema.XmlSchemaCollection; -import org.apache.ws.commons.schema.constants.Constants; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.core.io.Resource; -import org.springframework.util.Assert; -import org.springframework.util.ObjectUtils; -import org.springframework.xml.transform.ResourceSource; -import org.springframework.xml.xsd.XsdSchema; -import org.springframework.xml.xsd.XsdSchemaCollection; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public class CommonsXsdSchemaCollection implements XsdSchemaCollection, InitializingBean { - - private static final Log logger = LogFactory.getLog(CommonsXsdSchemaCollection.class); - - private XmlSchemaCollection schemaCollection = new XmlSchemaCollection(); - - private Resource[] xsdResources; - - public CommonsXsdSchemaCollection() { - } - - public CommonsXsdSchemaCollection(Resource[] xsdResources) { - this.xsdResources = xsdResources; - } - - public CommonsXsdSchemaCollection(XmlSchemaCollection schemaCollection) { - this.schemaCollection = schemaCollection; - } - - public void setXsds(Resource[] xsdResources) { - this.xsdResources = xsdResources; - } - - public void afterPropertiesSet() throws Exception { - if (!ObjectUtils.isEmpty(xsdResources)) { - Assert.notEmpty(xsdResources, "'xsds' must not be empty"); - XMLReader xmlReader = XMLReaderFactory.createXMLReader(); - xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); - for (int i = 0; i < xsdResources.length; i++) { - Assert.isTrue(xsdResources[i].exists(), "xsd '" + xsdResources[i] + "' does not exit"); - Source source = new ResourceSource(xmlReader, xsdResources[i]); - schemaCollection.read(source, null); - } - if (logger.isInfoEnabled()) { - logger.info("Loaded " + Arrays.asList(xsdResources)); - } - } - } - - public XsdSchema[] getXsdSchemas() { - XmlSchema[] schemas = schemaCollection.getXmlSchemas(); - List result = new ArrayList(schemas.length - 1); - for (int i = 0; i < schemas.length; i++) { - // Ignore the main XSD schema, which is always loaded - if (!Constants.URI_2001_SCHEMA_XSD.equals(schemas[i].getTargetNamespace())) { - result.add(new CommonsXsdSchema(schemas[i])); - } - } - return (XsdSchema[]) result.toArray(new XsdSchema[result.size()]); - } - - public String toString() { - StringBuffer buffer = new StringBuffer("CommonsXsdSchemaCollection"); - buffer.append('{'); - XmlSchema[] schemas = schemaCollection.getXmlSchemas(); - for (int i = 0; i < schemas.length; i++) { - if (!Constants.URI_2001_SCHEMA_XSD.equals(schemas[i].getTargetNamespace())) { - buffer.append(schemas[i].getTargetNamespace()); - if (i < schemas.length - 1) { - buffer.append(','); - } - } - } - buffer.append('}'); - return buffer.toString(); - } - - -} diff --git a/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11DefinitionTest.java b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11DefinitionTest.java new file mode 100644 index 00000000..1e8bdb0b --- /dev/null +++ b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/DefaultWsdl11DefinitionTest.java @@ -0,0 +1,75 @@ +/* + * Copyright ${YEAR} 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.wsdl.wsdl11; + +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.stream.StreamResult; + +import junit.framework.TestCase; + +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.ws.wsdl.wsdl11.provider.InliningXsdSchemaTypesProviderTest; +import org.springframework.xml.xsd.SimpleXsdSchema; +import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection; + +public class DefaultWsdl11DefinitionTest extends TestCase { + + private DefaultWsdl11Definition definition; + + private Transformer transformer; + + protected void setUp() throws Exception { + definition = new DefaultWsdl11Definition(); + TransformerFactory transformerFactory = TransformerFactory.newInstance(); + transformer = transformerFactory.newTransformer(); + } + + public void testSingle() throws Exception { + Resource resource = new ClassPathResource("single.xsd", getClass()); + SimpleXsdSchema schema = new SimpleXsdSchema(resource); + schema.afterPropertiesSet(); + definition.setSchema(schema); + + definition.setTargetNamespace("http://www.springframework.org/spring-ws/single/definitions"); + definition.setPortTypeName("Order"); + definition.setLocationUri("http://localhost:8080/"); + + definition.afterPropertiesSet(); + + transformer.transform(definition.getSource(), new StreamResult(System.out)); + + } + + public void testComplex() throws Exception { + Resource resource = new ClassPathResource("A.xsd", InliningXsdSchemaTypesProviderTest.class); + CommonsXsdSchemaCollection collection = new CommonsXsdSchemaCollection(new Resource[]{resource}); + collection.setInline(true); + collection.afterPropertiesSet(); + definition.setSchemaCollection(collection); + + definition.setTargetNamespace("http://www.springframework.org/spring-ws/single/definitions"); + definition.setPortTypeName("Order"); + definition.setLocationUri("http://localhost:8080/"); + + definition.afterPropertiesSet(); + + transformer.transform(definition.getSource(), new StreamResult(System.out)); + + } +} \ No newline at end of file diff --git a/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/XsdSchemaWsdl11DefinitionTest.java b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/XsdSchemaWsdl11DefinitionTest.java deleted file mode 100644 index 92315215..00000000 --- a/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/XsdSchemaWsdl11DefinitionTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright ${YEAR} 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.wsdl.wsdl11; - -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.stream.StreamResult; - -import junit.framework.*; - -import org.springframework.ws.wsdl.wsdl11.XsdSchemaWsdl11Definition; -import org.springframework.xml.xsd.XsdSchema; -import org.springframework.xml.xsd.SimpleXsdSchema; -import org.springframework.core.io.Resource; -import org.springframework.core.io.ClassPathResource; - -public class XsdSchemaWsdl11DefinitionTest extends TestCase { - - private XsdSchemaWsdl11Definition definition; - - protected void setUp() throws Exception { - definition = new XsdSchemaWsdl11Definition(); - } - - public void testDefinition() throws Exception { - ClassPathResource resource = new ClassPathResource("A.xsd", getClass()); - definition.setSchemas(new Resource[] {resource}); - definition.setTargetNamespace("http://springframework.org/spring-ws"); - definition.afterPropertiesSet(); - Transformer tr = TransformerFactory.newInstance().newTransformer(); - tr.setOutputProperty(OutputKeys.INDENT, "yes"); - tr.transform(definition.getSource(), new StreamResult(System.out)); - - - } -} \ No newline at end of file diff --git a/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProviderTest.java b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProviderTest.java new file mode 100644 index 00000000..dbc799bc --- /dev/null +++ b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/DefaultMessagesProviderTest.java @@ -0,0 +1,89 @@ +/* + * Copyright ${YEAR} 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.wsdl.wsdl11.provider; + +import javax.wsdl.Definition; +import javax.wsdl.Message; +import javax.wsdl.Part; +import javax.wsdl.Types; +import javax.wsdl.extensions.schema.Schema; +import javax.wsdl.factory.WSDLFactory; +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import junit.framework.TestCase; +import org.w3c.dom.Document; + +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.xml.sax.SaxUtils; + +public class DefaultMessagesProviderTest extends TestCase { + + private DefaultMessagesProvider provider; + + private Definition definition; + + private DocumentBuilder documentBuilder; + + protected void setUp() throws Exception { + provider = new DefaultMessagesProvider(); + WSDLFactory factory = WSDLFactory.newInstance(); + definition = factory.newDefinition(); + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + documentBuilderFactory.setNamespaceAware(true); + documentBuilder = documentBuilderFactory.newDocumentBuilder(); + } + + public void testAddMessages() throws Exception { + String definitionNamespace = "http://springframework.org/spring-ws"; + definition.addNamespace("tns", definitionNamespace); + definition.setTargetNamespace(definitionNamespace); + String schemaNamespace = "http://www.springframework.org/spring-ws/schema"; + definition.addNamespace("schema", schemaNamespace); + + Resource resource = new ClassPathResource("schema.xsd", getClass()); + Document schemaDocument = documentBuilder.parse(SaxUtils.createInputSource(resource)); + Types types = definition.createTypes(); + definition.setTypes(types); + Schema schema = (Schema) definition.getExtensionRegistry() + .createExtension(Types.class, new QName("http://www.w3.org/2001/XMLSchema", "schema")); + types.addExtensibilityElement(schema); + schema.setElement(schemaDocument.getDocumentElement()); + + provider.addMessages(definition); + + Message message = definition.getMessage(new QName(definitionNamespace, "GetOrderRequest")); + assertNotNull("Message not created", message); + Part part = message.getPart("GetOrderRequest"); + assertNotNull("Part not created", part); + assertEquals("Invalid element on part", new QName(schemaNamespace, "GetOrderRequest"), part.getElementName()); + + message = definition.getMessage(new QName(definitionNamespace, "GetOrderResponse")); + assertNotNull("Message not created", message); + part = message.getPart("GetOrderResponse"); + assertNotNull("Part not created", part); + assertEquals("Invalid element on part", new QName(schemaNamespace, "GetOrderResponse"), part.getElementName()); + + message = definition.getMessage(new QName(definitionNamespace, "GetOrderFault")); + assertNotNull("Message not created", message); + part = message.getPart("GetOrderFault"); + assertNotNull("Part not created", part); + assertEquals("Invalid element on part", new QName(schemaNamespace, "GetOrderFault"), part.getElementName()); + } +} \ No newline at end of file diff --git a/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProviderTest.java b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProviderTest.java new file mode 100644 index 00000000..38344196 --- /dev/null +++ b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/InliningXsdSchemaTypesProviderTest.java @@ -0,0 +1,92 @@ +/* + * Copyright ${YEAR} 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.wsdl.wsdl11.provider; + +import javax.wsdl.Definition; +import javax.wsdl.Types; +import javax.wsdl.extensions.schema.Schema; +import javax.wsdl.factory.WSDLFactory; + +import junit.framework.TestCase; + +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.xml.xsd.SimpleXsdSchema; +import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection; + +public class InliningXsdSchemaTypesProviderTest extends TestCase { + + private InliningXsdSchemaTypesProvider provider; + + private Definition definition; + + protected void setUp() throws Exception { + provider = new InliningXsdSchemaTypesProvider(); + WSDLFactory factory = WSDLFactory.newInstance(); + definition = factory.newDefinition(); + } + + public void testSingle() throws Exception { + String definitionNamespace = "http://springframework.org/spring-ws"; + definition.addNamespace("tns", definitionNamespace); + definition.setTargetNamespace(definitionNamespace); + String schemaNamespace = "http://www.springframework.org/spring-ws/schema"; + definition.addNamespace("schema", schemaNamespace); + + Resource resource = new ClassPathResource("schema.xsd", getClass()); + SimpleXsdSchema schema = new SimpleXsdSchema(resource); + schema.afterPropertiesSet(); + + provider.setSchema(schema); + + provider.addTypes(definition); + + Types types = definition.getTypes(); + assertNotNull("No types created", types); + assertEquals("Invalid amount of schemas", 1, types.getExtensibilityElements().size()); + + Schema wsdlSchema = (Schema) types.getExtensibilityElements().get(0); + assertNotNull("No element defined", wsdlSchema.getElement()); + } + + public void testComplex() throws Exception { + String definitionNamespace = "http://springframework.org/spring-ws"; + definition.addNamespace("tns", definitionNamespace); + definition.setTargetNamespace(definitionNamespace); + String schemaNamespace = "http://www.springframework.org/spring-ws/schema"; + definition.addNamespace("schema", schemaNamespace); + + Resource resource = new ClassPathResource("A.xsd", getClass()); + CommonsXsdSchemaCollection collection = new CommonsXsdSchemaCollection(new Resource[]{resource}); + collection.setInline(true); + collection.afterPropertiesSet(); + + provider.setSchemaCollection(collection); + + provider.addTypes(definition); + + Types types = definition.getTypes(); + assertNotNull("No types created", types); + assertEquals("Invalid amount of schemas", 2, types.getExtensibilityElements().size()); + + Schema wsdlSchema = (Schema) types.getExtensibilityElements().get(0); + assertNotNull("No element defined", wsdlSchema.getElement()); + + wsdlSchema = (Schema) types.getExtensibilityElements().get(1); + assertNotNull("No element defined", wsdlSchema.getElement()); + } +} \ No newline at end of file diff --git a/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11ProviderTest.java b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11ProviderTest.java new file mode 100644 index 00000000..539c40a8 --- /dev/null +++ b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap11ProviderTest.java @@ -0,0 +1,142 @@ +/* + * Copyright ${YEAR} 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.wsdl.wsdl11.provider; + +import java.util.Properties; +import javax.wsdl.Binding; +import javax.wsdl.BindingFault; +import javax.wsdl.BindingInput; +import javax.wsdl.BindingOperation; +import javax.wsdl.BindingOutput; +import javax.wsdl.Definition; +import javax.wsdl.Fault; +import javax.wsdl.Input; +import javax.wsdl.Operation; +import javax.wsdl.OperationType; +import javax.wsdl.Output; +import javax.wsdl.Port; +import javax.wsdl.PortType; +import javax.wsdl.Service; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap.SOAPBinding; +import javax.wsdl.extensions.soap.SOAPBody; +import javax.wsdl.extensions.soap.SOAPFault; +import javax.wsdl.extensions.soap.SOAPOperation; +import javax.wsdl.factory.WSDLFactory; +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +public class Soap11ProviderTest extends TestCase { + + private Soap11Provider provider; + + private Definition definition; + + protected void setUp() throws Exception { + provider = new Soap11Provider(); + WSDLFactory factory = WSDLFactory.newInstance(); + definition = factory.newDefinition(); + } + + public void testPopulateBinding() throws Exception { + String namespace = "http://springframework.org/spring-ws"; + definition.addNamespace("tns", namespace); + definition.setTargetNamespace(namespace); + + PortType portType = definition.createPortType(); + portType.setQName(new QName(namespace, "PortType")); + portType.setUndefined(false); + definition.addPortType(portType); + Operation operation = definition.createOperation(); + operation.setName("Operation"); + operation.setUndefined(false); + operation.setStyle(OperationType.REQUEST_RESPONSE); + portType.addOperation(operation); + Input input = definition.createInput(); + input.setName("Input"); + operation.setInput(input); + Output output = definition.createOutput(); + output.setName("Output"); + operation.setOutput(output); + Fault fault = definition.createFault(); + fault.setName("Fault"); + operation.addFault(fault); + + Properties soapActions = new Properties(); + soapActions.setProperty("Operation", namespace + "/Action"); + provider.setSoapActions(soapActions); + + provider.setServiceName("Service"); + + String locationUri = "http://localhost:8080/services"; + provider.setLocationUri(locationUri); + + provider.addBindings(definition); + provider.addServices(definition); + + Binding binding = definition.getBinding(new QName(namespace, "PortTypeSoap11")); + assertNotNull("No binding created", binding); + assertEquals("Invalid port type", portType, binding.getPortType()); + assertEquals("Invalid amount of extensibility elements", 1, binding.getExtensibilityElements().size()); + + SOAPBinding soapBinding = (SOAPBinding) binding.getExtensibilityElements().get(0); + assertEquals("Invalid style", "document", soapBinding.getStyle()); + assertEquals("Invalid amount of binding operations", 1, binding.getBindingOperations().size()); + + BindingOperation bindingOperation = binding.getBindingOperation("Operation", "Input", "Output"); + assertNotNull("No binding operation created", bindingOperation); + assertEquals("Invalid amount of extensibility elements", 1, bindingOperation.getExtensibilityElements().size()); + + SOAPOperation soapOperation = (SOAPOperation) bindingOperation.getExtensibilityElements().get(0); + assertEquals("Invalid SOAPAction", namespace + "/Action", soapOperation.getSoapActionURI()); + + BindingInput bindingInput = bindingOperation.getBindingInput(); + assertNotNull("No binding input", bindingInput); + assertEquals("Invalid name", "Input", bindingInput.getName()); + assertEquals("Invalid amount of extensibility elements", 1, bindingInput.getExtensibilityElements().size()); + SOAPBody soapBody = (SOAPBody) bindingInput.getExtensibilityElements().get(0); + assertEquals("Invalid soap body use", "literal", soapBody.getUse()); + + BindingOutput bindingOutput = bindingOperation.getBindingOutput(); + assertNotNull("No binding output", bindingOutput); + assertEquals("Invalid name", "Output", bindingOutput.getName()); + assertEquals("Invalid amount of extensibility elements", 1, bindingOutput.getExtensibilityElements().size()); + soapBody = (SOAPBody) bindingOutput.getExtensibilityElements().get(0); + assertEquals("Invalid soap body use", "literal", soapBody.getUse()); + + BindingFault bindingFault = bindingOperation.getBindingFault("Fault"); + assertNotNull("No binding fault", bindingFault); + assertEquals("Invalid amount of extensibility elements", 1, bindingFault.getExtensibilityElements().size()); + SOAPFault soapFault = (SOAPFault) bindingFault.getExtensibilityElements().get(0); + assertEquals("Invalid soap fault use", "literal", soapFault.getUse()); + + Service service = definition.getService(new QName(namespace, "Service")); + assertNotNull("No Service created", service); + assertEquals("Invalid amount of ports", 1, service.getPorts().size()); + + Port port = service.getPort("PortTypeSoap11"); + assertNotNull("No port created", port); + assertEquals("Invalid binding", binding, port.getBinding()); + assertEquals("Invalid amount of extensibility elements", 1, port.getExtensibilityElements().size()); + + SOAPAddress soapAddress = (SOAPAddress) port.getExtensibilityElements().get(0); + assertEquals("Invalid soap address", locationUri, soapAddress.getLocationURI()); + } + + +} \ No newline at end of file diff --git a/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12ProviderTest.java b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12ProviderTest.java new file mode 100644 index 00000000..84340f55 --- /dev/null +++ b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/Soap12ProviderTest.java @@ -0,0 +1,142 @@ +/* + * Copyright ${YEAR} 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.wsdl.wsdl11.provider; + +import java.util.Properties; +import javax.wsdl.Binding; +import javax.wsdl.BindingFault; +import javax.wsdl.BindingInput; +import javax.wsdl.BindingOperation; +import javax.wsdl.BindingOutput; +import javax.wsdl.Definition; +import javax.wsdl.Fault; +import javax.wsdl.Input; +import javax.wsdl.Operation; +import javax.wsdl.OperationType; +import javax.wsdl.Output; +import javax.wsdl.Port; +import javax.wsdl.PortType; +import javax.wsdl.Service; +import javax.wsdl.extensions.soap12.SOAP12Address; +import javax.wsdl.extensions.soap12.SOAP12Binding; +import javax.wsdl.extensions.soap12.SOAP12Body; +import javax.wsdl.extensions.soap12.SOAP12Fault; +import javax.wsdl.extensions.soap12.SOAP12Operation; +import javax.wsdl.factory.WSDLFactory; +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +public class Soap12ProviderTest extends TestCase { + + private Soap12Provider provider; + + private Definition definition; + + protected void setUp() throws Exception { + provider = new Soap12Provider(); + WSDLFactory factory = WSDLFactory.newInstance(); + definition = factory.newDefinition(); + } + + public void testPopulateBinding() throws Exception { + String namespace = "http://springframework.org/spring-ws"; + definition.addNamespace("tns", namespace); + definition.setTargetNamespace(namespace); + + PortType portType = definition.createPortType(); + portType.setQName(new QName(namespace, "PortType")); + portType.setUndefined(false); + definition.addPortType(portType); + Operation operation = definition.createOperation(); + operation.setName("Operation"); + operation.setUndefined(false); + operation.setStyle(OperationType.REQUEST_RESPONSE); + portType.addOperation(operation); + Input input = definition.createInput(); + input.setName("Input"); + operation.setInput(input); + Output output = definition.createOutput(); + output.setName("Output"); + operation.setOutput(output); + Fault fault = definition.createFault(); + fault.setName("Fault"); + operation.addFault(fault); + + Properties soapActions = new Properties(); + soapActions.setProperty("Operation", namespace + "/Action"); + provider.setSoapActions(soapActions); + + provider.setServiceName("Service"); + + String locationUri = "http://localhost:8080/services"; + provider.setLocationUri(locationUri); + + provider.addBindings(definition); + provider.addServices(definition); + + Binding binding = definition.getBinding(new QName(namespace, "PortTypeSoap12")); + assertNotNull("No binding created", binding); + assertEquals("Invalid port type", portType, binding.getPortType()); + assertEquals("Invalid amount of extensibility elements", 1, binding.getExtensibilityElements().size()); + + SOAP12Binding soapBinding = (SOAP12Binding) binding.getExtensibilityElements().get(0); + assertEquals("Invalid style", "document", soapBinding.getStyle()); + assertEquals("Invalid amount of binding operations", 1, binding.getBindingOperations().size()); + + BindingOperation bindingOperation = binding.getBindingOperation("Operation", "Input", "Output"); + assertNotNull("No binding operation created", bindingOperation); + assertEquals("Invalid amount of extensibility elements", 1, bindingOperation.getExtensibilityElements().size()); + + SOAP12Operation soapOperation = (SOAP12Operation) bindingOperation.getExtensibilityElements().get(0); + assertEquals("Invalid SOAPAction", namespace + "/Action", soapOperation.getSoapActionURI()); + + BindingInput bindingInput = bindingOperation.getBindingInput(); + assertNotNull("No binding input", bindingInput); + assertEquals("Invalid name", "Input", bindingInput.getName()); + assertEquals("Invalid amount of extensibility elements", 1, bindingInput.getExtensibilityElements().size()); + SOAP12Body soapBody = (SOAP12Body) bindingInput.getExtensibilityElements().get(0); + assertEquals("Invalid soap body use", "literal", soapBody.getUse()); + + BindingOutput bindingOutput = bindingOperation.getBindingOutput(); + assertNotNull("No binding output", bindingOutput); + assertEquals("Invalid name", "Output", bindingOutput.getName()); + assertEquals("Invalid amount of extensibility elements", 1, bindingOutput.getExtensibilityElements().size()); + soapBody = (SOAP12Body) bindingOutput.getExtensibilityElements().get(0); + assertEquals("Invalid soap body use", "literal", soapBody.getUse()); + + BindingFault bindingFault = bindingOperation.getBindingFault("Fault"); + assertNotNull("No binding fault", bindingFault); + assertEquals("Invalid amount of extensibility elements", 1, bindingFault.getExtensibilityElements().size()); + SOAP12Fault soapFault = (SOAP12Fault) bindingFault.getExtensibilityElements().get(0); + assertEquals("Invalid soap fault use", "literal", soapFault.getUse()); + + Service service = definition.getService(new QName(namespace, "Service")); + assertNotNull("No Service created", service); + assertEquals("Invalid amount of ports", 1, service.getPorts().size()); + + Port port = service.getPort("PortTypeSoap12"); + assertNotNull("No port created", port); + assertEquals("Invalid binding", binding, port.getBinding()); + assertEquals("Invalid amount of extensibility elements", 1, port.getExtensibilityElements().size()); + + SOAP12Address soapAddress = (SOAP12Address) port.getExtensibilityElements().get(0); + assertEquals("Invalid soap address", locationUri, soapAddress.getLocationURI()); + } + + +} \ No newline at end of file diff --git a/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProviderTest.java b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProviderTest.java new file mode 100644 index 00000000..9ad36847 --- /dev/null +++ b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SoapProviderTest.java @@ -0,0 +1,102 @@ +/* + * Copyright ${YEAR} 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.wsdl.wsdl11.provider; + +import java.util.Properties; +import javax.wsdl.Binding; +import javax.wsdl.Definition; +import javax.wsdl.Fault; +import javax.wsdl.Input; +import javax.wsdl.Operation; +import javax.wsdl.OperationType; +import javax.wsdl.Output; +import javax.wsdl.Port; +import javax.wsdl.PortType; +import javax.wsdl.Service; +import javax.wsdl.factory.WSDLFactory; +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +public class SoapProviderTest extends TestCase { + + private SoapProvider provider; + + private Definition definition; + + protected void setUp() throws Exception { + provider = new SoapProvider(); + WSDLFactory factory = WSDLFactory.newInstance(); + definition = factory.newDefinition(); + } + + public void testPopulateBinding() throws Exception { + String namespace = "http://springframework.org/spring-ws"; + definition.addNamespace("tns", namespace); + definition.setTargetNamespace(namespace); + + PortType portType = definition.createPortType(); + portType.setQName(new QName(namespace, "PortType")); + portType.setUndefined(false); + definition.addPortType(portType); + Operation operation = definition.createOperation(); + operation.setName("Operation"); + operation.setUndefined(false); + operation.setStyle(OperationType.REQUEST_RESPONSE); + portType.addOperation(operation); + Input input = definition.createInput(); + input.setName("Input"); + operation.setInput(input); + Output output = definition.createOutput(); + output.setName("Output"); + operation.setOutput(output); + Fault fault = definition.createFault(); + fault.setName("Fault"); + operation.addFault(fault); + + Properties soapActions = new Properties(); + soapActions.setProperty("Operation", namespace + "/Action"); + provider.setSoapActions(soapActions); + + provider.setServiceName("Service"); + + String locationUri = "http://localhost:8080/services"; + provider.setLocationUri(locationUri); + + provider.setCreateSoap11Binding(true); + provider.setCreateSoap12Binding(true); + + provider.addBindings(definition); + provider.addServices(definition); + + Binding binding = definition.getBinding(new QName(namespace, "PortTypeSoap11")); + assertNotNull("No SOAP 1.1 binding created", binding); + binding = definition.getBinding(new QName(namespace, "PortTypeSoap12")); + assertNotNull("No SOAP 1.2 binding created", binding); + + Service service = definition.getService(new QName(namespace, "Service")); + assertNotNull("No Service created", service); + assertEquals("Invalid amount of ports", 2, service.getPorts().size()); + + Port port = service.getPort("PortTypeSoap11"); + assertNotNull("No SOAP 1.1 port created", port); + port = service.getPort("PortTypeSoap12"); + assertNotNull("No SOAP 1.2 port created", port); + } + + +} \ No newline at end of file diff --git a/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProviderTest.java b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProviderTest.java new file mode 100644 index 00000000..169aa046 --- /dev/null +++ b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/provider/SuffixBasedPortTypesProviderTest.java @@ -0,0 +1,69 @@ +/* + * Copyright ${YEAR} 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.wsdl.wsdl11.provider; + +import javax.wsdl.Definition; +import javax.wsdl.Message; +import javax.wsdl.Operation; +import javax.wsdl.PortType; +import javax.wsdl.factory.WSDLFactory; +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +public class SuffixBasedPortTypesProviderTest extends TestCase { + + private SuffixBasedPortTypesProvider provider; + + private Definition definition; + + protected void setUp() throws Exception { + provider = new SuffixBasedPortTypesProvider(); + WSDLFactory factory = WSDLFactory.newInstance(); + definition = factory.newDefinition(); + } + + public void testAddPortTypes() throws Exception { + String namespace = "http://springframework.org/spring-ws"; + definition.addNamespace("tns", namespace); + definition.setTargetNamespace(namespace); + + Message message = definition.createMessage(); + message.setQName(new QName(namespace, "OperationRequest")); + definition.addMessage(message); + + message = definition.createMessage(); + message.setQName(new QName(namespace, "OperationResponse")); + definition.addMessage(message); + + message = definition.createMessage(); + message.setQName(new QName(namespace, "OperationFault")); + definition.addMessage(message); + + provider.setPortTypeName("PortType"); + provider.addPortTypes(definition); + + PortType portType = definition.getPortType(new QName(namespace, "PortType")); + assertNotNull("No port type created", portType); + + Operation operation = portType.getOperation("Operation", "OperationRequest", "OperationResponse"); + assertNotNull("No operation created", operation); + assertNotNull("No input created", operation.getInput()); + assertNotNull("No output created", operation.getOutput()); + assertFalse("No fault created", operation.getFaults().isEmpty()); + } +} \ No newline at end of file diff --git a/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/soap/SoapWsdl11DefinitionTest.java b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/soap/SoapWsdl11DefinitionTest.java deleted file mode 100644 index d6ce28dd..00000000 --- a/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/soap/SoapWsdl11DefinitionTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright ${YEAR} 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.wsdl.wsdl11.soap; - -import java.util.Properties; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.stream.StreamResult; - -import junit.framework.*; - - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -public class SoapWsdl11DefinitionTest extends TestCase { - - private SoapWsdl11Definition definition; - - protected void setUp() throws Exception { - definition = new MySoapWsdl11Definition(); - } - - public void testIt() throws Exception { - definition.setBeanName("wsdlDefinition"); - definition.setTargetNamespace("http://springframework.org/spring-ws"); - definition.setServiceName("Service"); - definition.setLocationUri("http://localhost"); - definition.setCreateSoap11Binding(true); - definition.setCreateSoap12Binding(true); - Properties soapActions = new Properties(); - soapActions.setProperty("Operation", "http://springframework.org/spring-ws/Action"); - definition.setSoapActions(soapActions); - definition.afterPropertiesSet(); - Transformer tr = TransformerFactory.newInstance().newTransformer(); - tr.setOutputProperty(OutputKeys.INDENT, "yes"); - tr.transform(definition.getSource(), new StreamResult(System.out)); - } - - private static class MySoapWsdl11Definition extends SoapWsdl11Definition { - - protected void addPortTypes(Document document, Element definitions) { - Element portType = createWsdlElement(document, "portType"); - definitions.appendChild(portType); - portType.setAttribute("name", "PortType"); - Element operation = createWsdlElement(document, "operation"); - portType.appendChild(operation); - operation.setAttribute("name", "Operation"); - Element input = createWsdlElement(document, "input"); - operation.appendChild(input); -// input.setAttribute("name", "Input"); - Element output = createWsdlElement(document, "output"); - operation.appendChild(output); -// output.setAttribute("name", "Output"); - Element fault = createWsdlElement(document, "fault"); - operation.appendChild(fault); - fault.setAttribute("name", "Fault"); - } - } -} \ No newline at end of file diff --git a/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/visitor/DefaultBindingVisitorTest.java b/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/visitor/DefaultBindingVisitorTest.java deleted file mode 100644 index fa1ce1fe..00000000 --- a/sandbox/src/test/java/org/springframework/ws/wsdl/wsdl11/visitor/DefaultBindingVisitorTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright ${YEAR} 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.wsdl.wsdl11.visitor; - -import java.util.Iterator; -import javax.wsdl.Definition; -import javax.wsdl.Fault; -import javax.wsdl.Operation; -import javax.wsdl.PortType; -import javax.wsdl.factory.WSDLFactory; -import javax.wsdl.xml.WSDLReader; -import javax.wsdl.xml.WSDLWriter; -import javax.xml.namespace.QName; - -import org.springframework.core.io.ClassPathResource; -import org.springframework.xml.sax.SaxUtils; - -import org.custommonkey.xmlunit.XMLTestCase; -import org.w3c.dom.Document; - -public class DefaultBindingVisitorTest extends XMLTestCase { - - private DefaultBindingVisitor visitor; - - private Definition definition; - - private Definition expected; - - private WSDLFactory factory; - - protected void setUp() throws Exception { - factory = WSDLFactory.newInstance(); - definition = factory.newDefinition(); - visitor = new DefaultBindingVisitor(); - WSDLReader reader = factory.newWSDLReader(); - definition = reader.readWSDL(null, - SaxUtils.createInputSource(new ClassPathResource("defaultBindingVisitorTest-input.wsdl", getClass()))); - expected = reader.readWSDL(null, - SaxUtils.createInputSource(new ClassPathResource("defaultBindingVisitorTest-expected.wsdl", getClass()))); - } - - public void testDefaultBindingVisitor() throws Exception { - visitor.startDefinition(definition); - PortType portType = definition.getPortType(new QName("http://springframework.org/spring-ws", "PortType")); - visitor.startPortType(portType); - for (Iterator operationIter = portType.getOperations().iterator(); operationIter.hasNext();) { - Operation operation = (Operation) operationIter.next(); - visitor.startOperation(operation); - if (operation.getInput() != null) { - visitor.input(operation.getInput()); - } - if (operation.getOutput() != null) { - visitor.output(operation.getOutput()); - } - for (Iterator faultIter = operation.getFaults().values().iterator(); faultIter.hasNext();) { - Fault fault = (Fault) faultIter.next(); - visitor.fault(fault); - } - visitor.endOperation(operation); - } - visitor.endPortType(portType); - visitor.endDefinition(definition); - - WSDLWriter writer = factory.newWSDLWriter(); - Document resultDocument = writer.getDocument(definition); - Document expectedDocument = writer.getDocument(expected); - assertXMLEqual("Invalid WSDL generated", expectedDocument, resultDocument); - } -} \ No newline at end of file diff --git a/sandbox/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollectionTest.java b/sandbox/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollectionTest.java deleted file mode 100644 index 63d5dea6..00000000 --- a/sandbox/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollectionTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright ${YEAR} 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.xml.xsd.commons; - -import javax.xml.transform.dom.DOMResult; - -import junit.framework.TestCase; - -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.xml.xsd.AbstractXsdSchemaTestCase; -import org.springframework.xml.xsd.XsdSchema; -import org.springframework.xml.sax.SaxUtils; - -import org.w3c.dom.Document; - -public class CommonsXsdSchemaCollectionTest extends TestCase { - - private CommonsXsdSchemaCollection collection; - - protected void setUp() throws Exception { - collection = new CommonsXsdSchemaCollection(); - } - - public void testSingle() throws Exception { - Resource resource = new ClassPathResource("single.xsd", AbstractXsdSchemaTestCase.class); - collection.setXsds(new Resource[]{resource}); - collection.afterPropertiesSet(); - assertEquals("Invalid amount of XSDs loaded", 1, collection.getXsdSchemas().length); - } - - public void testIncludes() throws Exception { - Resource resource = new ClassPathResource("including.xsd", AbstractXsdSchemaTestCase.class); - collection.setXsds(new Resource[] { resource}); - collection.afterPropertiesSet(); - assertEquals("Invalid amount of XSDs loaded", 2, collection.getXsdSchemas().length); - } - - public void testImports() throws Exception { - Resource resource = new ClassPathResource("importing.xsd", AbstractXsdSchemaTestCase.class); - collection.setXsds(new Resource[] { resource}); - collection.afterPropertiesSet(); - assertEquals("Invalid amount of XSDs loaded", 2, collection.getXsdSchemas().length); - } - - public void testDuplicates() throws Exception { - Resource resource = new ClassPathResource("single.xsd", AbstractXsdSchemaTestCase.class); - collection.setXsds(new Resource[] { resource, resource}); - collection.afterPropertiesSet(); - assertEquals("Invalid amount of XSDs loaded", 1, collection.getXsdSchemas().length); - } - -} \ No newline at end of file diff --git a/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/A.xsd b/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/A.xsd new file mode 100644 index 00000000..dd680b01 --- /dev/null +++ b/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/A.xsd @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/ABC.xsd b/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/ABC.xsd new file mode 100644 index 00000000..257821fe --- /dev/null +++ b/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/ABC.xsd @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + diff --git a/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/B.xsd b/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/B.xsd new file mode 100644 index 00000000..cb797af5 --- /dev/null +++ b/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/B.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/C.xsd b/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/C.xsd similarity index 100% rename from sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/C.xsd rename to sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/C.xsd diff --git a/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/D.xsd b/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/D.xsd similarity index 100% rename from sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/D.xsd rename to sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/D.xsd diff --git a/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/schema.xsd b/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/schema.xsd new file mode 100644 index 00000000..ac7e7480 --- /dev/null +++ b/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/provider/schema.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/soap/portType.wsdl b/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/soap/portType.wsdl deleted file mode 100644 index a8e1978f..00000000 --- a/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/soap/portType.wsdl +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - diff --git a/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/visitor/defaultBindingVisitorTest-expected.wsdl b/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/visitor/defaultBindingVisitorTest-expected.wsdl deleted file mode 100644 index b5665aae..00000000 --- a/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/visitor/defaultBindingVisitorTest-expected.wsdl +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/visitor/defaultBindingVisitorTest-input.wsdl b/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/visitor/defaultBindingVisitorTest-input.wsdl deleted file mode 100644 index c9bdf0cc..00000000 --- a/sandbox/src/test/resources/org/springframework/ws/wsdl/wsdl11/visitor/defaultBindingVisitorTest-input.wsdl +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file