Done working on WSDL in sandbox.

This commit is contained in:
Arjen Poutsma
2008-03-08 02:47:59 +00:00
parent b56e6313ca
commit a833243ac2
53 changed files with 2902 additions and 1957 deletions

View File

@@ -68,9 +68,7 @@
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jmx</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
<artifactId>spring-test</artifactId>
</dependency>
<!-- JEE dependencies -->
<dependency>

View File

@@ -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.
* <p/>
* 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();
}
}

View File

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

View File

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

View File

@@ -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 + " <include/> 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 + " <include/> 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<Element>();
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 + " <include/> 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 + " <import/> has no schemaLocation attribute");
String importNamespace = element.getAttribute("namespace");
Assert.hasText(importNamespace, schemaResource + " <import/> 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 + " <include/> 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);
}
}
}

View File

@@ -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 <code>Definition</code>
* @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.
* <p/>
* Default implementation sets the name of the port type to the defined value.
*
* @param portType the WSDL4J <code>PortType</code>
* @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 <code>null</code> to indicate that a message should not be coupled to an operation.
*
* @param message the WSDL4J <code>Message</code>
* @return the operation name; or <code>null</code>
*/
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 <code>true</code> if to be included as input; <code>false</code> 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.
* <p/>
* Default implementation sets the input name to the message name.
*
* @param definition the WSDL4J <code>Definition</code>
* @param input the WSDL4J <code>Input</code>
*/
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 <code>true</code> if to be included as output; <code>false</code> 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.
* <p/>
* Default implementation sets the output name to the message name.
*
* @param definition the WSDL4J <code>Definition</code>
* @param output the WSDL4J <code>Output</code>
*/
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 <code>true</code> if to be included as fault; <code>false</code> 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.
* <p/>
* Default implementation sets the fault name to the message name.
*
* @param definition the WSDL4J <code>Definition</code>
* @param fault the WSDL4J <code>Fault</code>
*/
protected void populateFault(Definition definition, Fault fault) {
fault.setName(fault.getMessage().getQName().getLocalPart());
}
/**
* Returns the {@link OperationType} for the given operation.
* <p/>
* 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 <code>Operation</code>
* @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;
}
}
}

View File

@@ -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}.
* <p/>
* 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;
}

View File

@@ -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.
* <p/>
* Creates a <code>binding</code> that matches any present <code>portType</code>, and a service containing
* <code>port</code>s that match the <code>binding</code>s. 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.
* <p/>
* Calls the various <code>populate</code> methods with the created WSDL4J objects.
*
* @param definition the WSDL4J <code>Definition</code>
* @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.
* <p/>
* Default implementation sets the binding name to the port type name with the {@link #getBindingSuffix() suffix}
* appended to it.
*
* @param definition the WSDL4J <code>Definition</code>
* @param binding the WSDL4J <code>Binding</code>
*/
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.
* <p/>
* Default implementation sets the name of the binding operation to the name of the operation.
*
* @param definition the WSDL4J <code>Definition</code>
* @param bindingOperation the WSDL4J <code>BindingOperation</code>
* @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.
* <p/>
* Default implementation set the name of the binding input to the name of the input.
*
* @param definition the WSDL4J <code>Definition</code>
* @param bindingInput the WSDL4J <code>BindingInput</code>
* @param input the corresponding WSDL4J <code>Input</code> @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.
* <p/>
* Default implementation sets the name of the binding output to the name of the output.
*
* @param definition the WSDL4J <code>Definition</code>
* @param bindingOutput the WSDL4J <code>BindingOutput</code>
* @param output the corresponding WSDL4J <code>Output</code> @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.
* <p/>
* Default implementation set the name of the binding fault to the name of the fault.
*
* @param bindingFault the WSDL4J <code>BindingFault</code>
* @param fault the corresponding WSDL4J <code>Fault</code> @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 <code>Definition</code>
* @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.
* <p/>
* Default implementation sets the name to the {@link #setServiceName(String) serviceName} property.
*
* @param service the WSDL4J <code>Service</code>
* @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.
* <p/>
* Default implementation sets the port name to the binding name.
*
* @param definition the WSDL4J <code>Definition</code>
* @param port the WSDL4J <code>Port</code>
* @throws WSDLException in case of errors
*/
protected void populatePort(Definition definition, Port port) throws WSDLException {
port.setName(port.getBinding().getQName().getLocalPart());
}
}

View File

@@ -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}.
* <p/>
* 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.
* <p/>
* 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 <code>true</code> if to be included as message; <code>false</code> 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.
* <p/>
* Default implementation sets the name of the message to the element name.
*
* @param definition the WSDL4J <code>Definition</code>
* @param message the WSDL4J <code>Message</code>
* @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.
* <p/>
* Default implementation sets the element name of the part.
*
* @param definition the WSDL4J <code>Definition</code>
* @param part the WSDL4J <code>Part</code>
* @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());
}
}

View File

@@ -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.
* <p/>
* Default implementation sets the name to the {@link #setServiceName(String) serviceName} property.
*
* @param service the WSDL4J <code>Service</code>
* @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.
* <p/>
* Default implementation sets the port name to the binding name.
*
* @param port the WSDL4J <code>Port</code>
* @param binding the corresponding WSDL4J <code>Binding</code>
* @throws WSDLException in case of errors
*/
protected void populatePort(Port port, Binding binding) throws WSDLException {
port.setName(binding.getQName().getLocalPart());
}
}

View File

@@ -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}.
* <p/>
* 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();
}

View File

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

View File

@@ -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}.
* <p/>
* 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;
}

View File

@@ -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}.
* <p/>
* 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;
}

View File

@@ -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}.
* <p/>
* 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;
}

View File

@@ -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.
* <p/>
* 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}.
* <p/>
* Sets the {@link #setBindingSuffix(String) binding suffix} to <code>Soap11</code>.
*/
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.
* <p/>
* 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 <code>Definition</code>
* @param binding the WSDL4J <code>Binding</code>
*/
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.
* <p/>
* Default implementation sets the binding style to <code>"document"</code>, and set the transport URI to the {@link
* #setTransportUri(String) transportUri} property value. Subclasses can override this behavior.
*
* @param soapBinding the WSDL4J <code>SOAPBinding</code>
* @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.
* <p/>
* Default implementation calls {@link DefaultConcretePartProvider#populateBindingFault(Definition, BindingFault,
* Fault)}, creates a {@link SOAPFault}, and calls {@link #populateSoapFault(BindingFault, SOAPFault)}.
*
* @param definition the WSDL4J <code>Definition</code>
* @param bindingFault the WSDL4J <code>BindingFault</code>
* @param fault the corresponding WSDL4J <code>Fault</code> @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.
* <p/>
* Default implementation sets the use style to <code>"literal"</code>, and sets the name equal to the binding
* fault. Subclasses can override this behavior.
*
* @param bindingFault the WSDL4J <code>BindingFault</code>
* @param soapFault the WSDL4J <code>SOAPFault</code>
* @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.
* <p/>
* 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 <code>Definition</code>
* @param bindingInput the WSDL4J <code>BindingInput</code>
* @param input the corresponding WSDL4J <code>Input</code> @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.
* <p/>
* Default implementation sets the use style to <code>"literal"</code>. Subclasses can override this behavior.
*
* @param soapBody the WSDL4J <code>SOAPBody</code>
* @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.
* <p/>
* 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 <code>Definition</code>
* @param bindingOperation the WSDL4J <code>BindingOperation</code>
* @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.
* <p/>
* Default implementation sets <code>SOAPAction</code> to the corresponding {@link
* #setSoapActions(java.util.Properties) soapActions} property, and defaults to "".
*
* @param soapOperation the WSDL4J <code>SOAPOperation</code>
* @param bindingOperation the WSDL4J <code>BindingOperation</code>
* @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.
* <p/>
* Default implementation calls {@link DefaultConcretePartProvider#populateBindingOutput(Definition, BindingOutput,
* Output)}, creates a {@link SOAPBody}, and calls {@link #populateSoapBody(SOAPBody)}.
*
* @param definition the WSDL4J <code>Definition</code>
* @param bindingOutput the WSDL4J <code>BindingOutput</code>
* @param output the corresponding WSDL4J <code>Output</code> @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.
* <p/>
* 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 <code>Port</code>
* @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 <code>SOAPAddress</code>
* @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 <code>Definition</code>
* @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));
}
}

View File

@@ -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.
* <p/>
* 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}.
* <p/>
* Sets the {@link #setBindingSuffix(String) binding suffix} to <code>Soap12</code>.
*/
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.
* <p/>
* 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 <code>Definition</code>
* @param binding the WSDL4J <code>Binding</code>
*/
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.
* <p/>
* Default implementation sets the binding style to <code>"document"</code>, and set the transport URI to the {@link
* #setTransportUri(String) transportUri} property value. Subclasses can override this behavior.
*
* @param soapBinding the WSDL4J <code>SOAPBinding</code>
* @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.
* <p/>
* 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 <code>Definition</code>
* @param bindingFault the WSDL4J <code>BindingFault</code>
* @param fault the corresponding WSDL4J <code>Fault</code> @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.
* <p/>
* Default implementation sets the use style to <code>"literal"</code>, and sets the name equal to the binding
* fault. Subclasses can override this behavior.
*
* @param bindingFault the WSDL4J <code>BindingFault</code>
* @param soapFault the WSDL4J <code>SOAPFault</code>
* @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.
* <p/>
* 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 <code>Definition</code>
* @param bindingInput the WSDL4J <code>BindingInput</code>
* @param input the corresponding WSDL4J <code>Input</code> @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.
* <p/>
* Default implementation sets the use style to <code>"literal"</code>. Subclasses can override this behavior.
*
* @param soapBody the WSDL4J <code>SOAPBody</code>
* @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.
* <p/>
* 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 <code>Definition</code>
* @param bindingOperation the WSDL4J <code>BindingOperation</code>
* @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.
* <p/>
* Default implementation sets <code>SOAPAction</code> to the corresponding {@link
* #setSoapActions(java.util.Properties) soapActions} property, and defaults to "".
*
* @param soapOperation the WSDL4J <code>SOAPOperation</code>
* @param bindingOperation the WSDL4J <code>BindingOperation</code>
* @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.
* <p/>
* 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 <code>Definition</code>
* @param bindingOutput the WSDL4J <code>BindingOutput</code>
* @param output the corresponding WSDL4J <code>Output</code> @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.
* <p/>
* 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 <code>Port</code>
* @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 <code>SOAPAddress</code>
* @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 <code>Definition</code>
* @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));
}
}

View File

@@ -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}.
* <p/>
* 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.
* <p/>
* 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
* <code>true</code> and <code>false</code> 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.
* <p/>
* Defaults to <code>true</code>.
*/
public void setCreateSoap11Binding(boolean createSoap11Binding) {
this.createSoap11Binding = createSoap11Binding;
}
/**
* Indicates whether a SOAP 1.2 binding should be created.
* <p/>
* Defaults to <code>false</code>.
*/
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);
}
}
}

View File

@@ -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.
* <p/>
* This implementation checks whether the message name ends with the {@link #setRequestSuffix(String)
* requestSuffix}.
*
* @param message the message
* @return <code>true</code> if to be included as input; <code>false</code> 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.
* <p/>
* This implementation checks whether the message name ends with the {@link #setResponseSuffix(String)
* responseSuffix}.
*
* @param message the message
* @return <code>true</code> if to be included as output; <code>false</code> 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.
* <p/>
* This implementation checks whether the message name ends with the {@link #setFaultSuffix(String) faultSuffix}.
*
* @param message the message
* @return <code>true</code> if to be included as fault; <code>false</code> 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();
}
}

View File

@@ -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}.
* <p/>
* 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;
}

View File

@@ -0,0 +1,5 @@
<html>
<body>
Provides a contribution strategy for WSDL definitions.
</body>
</html>

View File

@@ -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, "<portType/> 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, "<operation/> 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, "<fault/> 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, "<binding/> 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();
}

View File

@@ -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";
}
}

View File

@@ -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";
}
}

View File

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

View File

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

View File

@@ -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 <code>Wsdl11DefinitionBuilder</code> implementations that use WSDL4J and contain a concrete
* part. Creates a <code>binding</code> that matches any present <code>portType</code>. 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.
* <p/>
* Default implementation sets the binding name to the port type name with the suffix {@link Binding} appended to
* it.
*
* @param binding the WSDL4J <code>Binding</code>
* @param portType the corresponding <code>PortType</code>
* @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.
* <p/>
* Default implementation sets the name of the binding operation to the name of the operation.
*
* @param bindingOperation the WSDL4J <code>BindingOperation</code>
* @param operation the corresponding WSDL4J <code>Operation</code>
* @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.
* <p/>
* Default implementation set the name of the binding input to the name of the input.
*
* @param bindingInput the WSDL4J <code>BindingInput</code>
* @param input the corresponding WSDL4J <code>Input</code>
* @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.
* <p/>
* Default implementation set the name of the binding output to the name of the output.
*
* @param bindingOutput the WSDL4J <code>BindingOutput</code>
* @param output the corresponding WSDL4J <code>Output</code>
* @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.
* <p/>
* Default implementation set the name of the binding fault to the name of the fault.
*
* @param bindingFault the WSDL4J <code>BindingFault</code>
* @param fault the corresponding WSDL4J <code>Fault</code>
* @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;
}
}

View File

@@ -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.
* <p/>
* Default implementation sets the port name to the port type name with the suffix {@link Port} appended to it.
*
* @param port the WSDL4J <code>Port</code>
* @param binding the corresponding WSDL4J <code>Binding</code>
* @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;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:1"
xmlns:tns="urn:1" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:include schemaLocation="B.xsd"/>
<xsd:simpleType name="A">
<xsd:restriction base="tns:B"/>
</xsd:simpleType>
</xsd:schema>

View File

@@ -0,0 +1,16 @@
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="urn:2" xmlns:tns="urn:1"
attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:1">
<xsd:import namespace="urn:2" schemaLocation="D.xsd"/>
<xsd:simpleType name="A">
<xsd:restriction base="tns:B"/>
</xsd:simpleType>
<xsd:complexType name="B">
<xsd:sequence>
<xsd:element name="c" type="tns:C"/>
<xsd:element name="d" type="ns0:D"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="C">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:schema>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:1"
xmlns="urn:1"
xmlns:imported="urn:2" elementFormDefault="qualified">
<xsd:include schemaLocation="C.xsd"/>
<xsd:import schemaLocation="D.xsd" namespace="urn:2"/>
<xsd:complexType name="B">
<xsd:sequence>
<xsd:element type="C" name="c"/>
<xsd:element type="imported:D" name="d"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/spring-ws/schema"
xmlns="http://www.springframework.org/spring-ws/schema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:simpleType name="customType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:element name="GetOrderRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetOrderResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetOrderFault">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

View File

@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://springframework.org/spring-ws"
name="wsdlDefinition"
targetNamespace="http://springframework.org/spring-ws">
<wsdl:portType name="PortType">
<wsdl:operation name="Operation">
<wsdl:input/>
<wsdl:output/>
<wsdl:fault name="Fault"/>
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>

View File

@@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://springframework.org/spring-ws"
targetNamespace="http://springframework.org/spring-ws">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://springframework.org/spring-ws">
<element name="Element" type="string"/>
</schema>
</wsdl:types>
<wsdl:message name="Message">
<wsdl:part element="tns:string" name="Message"/>
</wsdl:message>
<wsdl:portType name="PortType">
<wsdl:operation name="OneWay">
<wsdl:input message="tns:Message"/>
</wsdl:operation>
<wsdl:operation name="RequestResponse">
<wsdl:input message="tns:Message"/>
<wsdl:output message="tns:Message"/>
<wsdl:fault name="Fault" message="tns:Message"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="PortTypeBinding" type="tns:PortType">
<wsdl:operation name="OneWay">
<wsdl:input/>
</wsdl:operation>
<wsdl:operation name="RequestResponse">
<wsdl:input/>
<wsdl:output/>
<wsdl:fault name="Fault"/>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>

View File

@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://springframework.org/spring-ws"
targetNamespace="http://springframework.org/spring-ws">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://springframework.org/spring-ws">
<element name="Element" type="string"/>
</schema>
</wsdl:types>
<wsdl:message name="Message">
<wsdl:part element="tns:string" name="Message"/>
</wsdl:message>
<wsdl:portType name="PortType">
<wsdl:operation name="OneWay">
<wsdl:input message="tns:Message"/>
</wsdl:operation>
<wsdl:operation name="RequestResponse">
<wsdl:input message="tns:Message"/>
<wsdl:output message="tns:Message"/>
<wsdl:fault name="Fault" message="tns:Message"/>
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>