Moved new WSDL design over from sandbox

This commit is contained in:
Arjen Poutsma
2008-03-08 03:07:16 +00:00
parent 0bfbe2f2a0
commit c425dc8ba3
45 changed files with 40 additions and 427 deletions

View File

@@ -33,6 +33,19 @@ import org.springframework.xml.xsd.XsdSchemaCollection;
* 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.
* <p/>
* Example configuration:
* <pre>
* &lt;bean id=&quot;airline&quot; class=&quot;org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition&quot;&gt;
* &lt;property name=&quot;schema&quot;&gt;
* &lt;bean class=&quot;org.springframework.xml.xsd.SimpleXsdSchema&quot;&gt;
* &lt;property name=&quot;xsd&quot; value=&quot;/WEB-INF/airline.xsd&quot;/&gt;
* &lt;/bean&gt;
* &lt;/property&gt;
* &lt;property name=&quot;portTypeName&quot; value=&quot;Airline&quot;/&gt;
* &lt;property name=&quot;locationUri&quot; value=&quot;http://localhost:8080/airline/services&quot;/&gt;
* &lt;/bean&gt;
* </pre>
*
* @author Arjen Poutsma
* @since 1.5.0

View File

@@ -41,6 +41,8 @@ import javax.xml.namespace.QName;
*
* @author Arjen Poutsma
* @since 1.0.0
* @deprecated as of Spring Web Services 1.5: superseded by {@link org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition}
* and the {@link org.springframework.ws.wsdl.wsdl11.provider} package
*/
public abstract class AbstractBindingWsdl4jDefinitionBuilder extends AbstractWsdl4jDefinitionBuilder {

View File

@@ -45,6 +45,8 @@ import javax.xml.namespace.QName;
* @author Arjen Poutsma
* @see #setLocationUri(String)
* @since 1.0.0
* @deprecated as of Spring Web Services 1.5: superseded by {@link org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition}
* and the {@link org.springframework.ws.wsdl.wsdl11.provider} package
*/
public abstract class AbstractSoap11Wsdl4jDefinitionBuilder extends AbstractBindingWsdl4jDefinitionBuilder {

View File

@@ -46,6 +46,8 @@ import javax.xml.namespace.QName;
* @author Alex Marshall
* @see #setLocationUri(String)
* @since 1.5.0
* @deprecated as of Spring Web Services 1.5: superseded by {@link org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition}
* and the {@link org.springframework.ws.wsdl.wsdl11.provider} package
*/
public abstract class AbstractSoap12Wsdl4jDefinitionBuilder extends AbstractBindingWsdl4jDefinitionBuilder {
@@ -53,9 +55,7 @@ public abstract class AbstractSoap12Wsdl4jDefinitionBuilder extends AbstractBind
private static final String WSDL_SOAP_PREFIX = "soap12";
/**
* The default soap12:binding transport attribute value.
*/
/** The default soap12:binding transport attribute value. */
public static final String DEFAULT_TRANSPORT_URI = "http://schemas.xmlsoap.org/soap/http";
private String transportUri = DEFAULT_TRANSPORT_URI;
@@ -72,16 +72,12 @@ public abstract class AbstractSoap12Wsdl4jDefinitionBuilder extends AbstractBind
this.transportUri = transportUri;
}
/**
* Sets the value used for the soap12:address location attribute value.
*/
/** Sets the value used for the soap12:address location attribute value. */
public void setLocationUri(String locationUri) {
this.locationUri = locationUri;
}
/**
* Adds the WSDL SOAP namespace to the definition.
*/
/** Adds the WSDL SOAP namespace to the definition. */
protected void populateDefinition(Definition definition) throws WSDLException {
definition.addNamespace(WSDL_SOAP_PREFIX, WSDL_SOAP_NAMESPACE_URI);
}

View File

@@ -25,6 +25,7 @@ import javax.xml.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.ws.wsdl.WsdlDefinitionException;
import org.springframework.ws.wsdl.wsdl11.Wsdl11Definition;
import org.springframework.ws.wsdl.wsdl11.Wsdl11DefinitionBuilder;
@@ -37,6 +38,8 @@ import org.springframework.ws.wsdl.wsdl11.Wsdl4jDefinitionException;
*
* @author Arjen Poutsma
* @since 1.0.0
* @deprecated as of Spring Web Services 1.5: superseded by {@link org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition}
* and the {@link org.springframework.ws.wsdl.wsdl11.provider} package
*/
public abstract class AbstractWsdl4jDefinitionBuilder implements Wsdl11DefinitionBuilder {

View File

@@ -82,6 +82,8 @@ import org.springframework.xml.namespace.QNameUtils;
* @see #setRequestSuffix(String)
* @see #setResponseSuffix(String)
* @since 1.0.0
* @deprecated as of Spring Web Services 1.5: superseded by {@link org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition}
* and the {@link org.springframework.ws.wsdl.wsdl11.provider} package
*/
public class XsdBasedSoap11Wsdl4jDefinitionBuilder extends AbstractSoap11Wsdl4jDefinitionBuilder
implements InitializingBean {

View File

@@ -83,6 +83,8 @@ import org.springframework.xml.namespace.QNameUtils;
* @see #setRequestSuffix(String)
* @see #setResponseSuffix(String)
* @since 1.5.0
* @deprecated as of Spring Web Services 1.5: superseded by {@link org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition}
* and the {@link org.springframework.ws.wsdl.wsdl11.provider} package
*/
public class XsdBasedSoap12Wsdl4jDefinitionBuilder extends AbstractSoap12Wsdl4jDefinitionBuilder
implements InitializingBean {
@@ -288,7 +290,7 @@ public class XsdBasedSoap12Wsdl4jDefinitionBuilder extends AbstractSoap12Wsdl4jD
definition.addNamespace(prefix, elementName.getNamespaceURI());
break;
}
i++;
i++;
}
}
Message message = definition.createMessage();

View File

@@ -26,23 +26,26 @@ import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.xml.namespace.QNameUtils;
import org.springframework.xml.sax.SaxUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
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.namespace.QNameUtils;
import org.springframework.xml.sax.SaxUtils;
/**
* Helper class for dealing with XSD schemas. Exposes the target namespace, and the list of qualified names declared in
* a schema.
*
* @author Arjen Poutsma
* @since 1.0.2
* @deprecated as of Spring Web Services 1.5: superseded by {@link org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition}
* and the {@link org.springframework.ws.wsdl.wsdl11.provider} package
*/
class XsdSchemaHelper {

View File

@@ -1,5 +1,6 @@
<html>
<body>
Provides a strategy for WSDL building. Used by DynamicWsdl11Definition to generate WSDL definitions at runtime.
<strong>Deprecated</strong> as of Spring Web Services 1.5: superseded by the <code>DefaultWsdl11Definition</code>
and <code>org.springframework.ws.wsdl.wsdl11.provider</code> package.
</body>
</html>

View File

@@ -1,31 +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 javax.wsdl.Binding;
import javax.wsdl.Definition;
import javax.wsdl.WSDLException;
/**
* @author Arjen Poutsma
* @since 1.5.0
*/
public interface BindingProvider {
void addBinding(Definition definition) throws WSDLException;
}

View File

@@ -1,200 +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.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.PortType;
import javax.wsdl.WSDLException;
import javax.xml.namespace.QName;
/**
* @author Arjen Poutsma
* @since 1.5.0
*/
public class DefaultBindingProvider implements BindingProvider {
/** The suffix used to create a binding name from a port type name. */
public static final String DEFAULT_BINDING_SUFFIX = "Binding";
private String bindingSuffix = DEFAULT_BINDING_SUFFIX;
public String getBindingSuffix() {
return bindingSuffix;
}
public void setBindingSuffix(String bindingSuffix) {
this.bindingSuffix = bindingSuffix;
}
/**
* Creates a {@link Binding} for each {@link PortType} in the definition, and calls {@link
* #populateBinding(javax.wsdl.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(javax.wsdl.Definition,javax.wsdl.Binding)
* @see #populateBindingOperation(javax.wsdl.Definition,javax.wsdl.BindingOperation)
* @see #populateBindingInput(javax.wsdl.Definition,javax.wsdl.BindingInput,javax.wsdl.Input)
* @see #populateBindingOutput(javax.wsdl.Definition,javax.wsdl.BindingOutput,javax.wsdl.Output)
* @see #populateBindingFault(javax.wsdl.Definition,javax.wsdl.BindingFault,javax.wsdl.Fault)
*/
public void addBinding(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, portType);
binding.setUndefined(false);
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, PortType portType)
throws WSDLException {
for (Iterator operationIterator = portType.getOperations().iterator(); operationIterator.hasNext();) {
Operation operation = (Operation) operationIterator.next();
BindingOperation bindingOperation = definition.createBindingOperation();
bindingOperation.setOperation(operation);
populateBindingOperation(definition, bindingOperation);
if (operation.getStyle() == null || operation.getStyle().equals(OperationType.REQUEST_RESPONSE)) {
createBindingInput(definition, operation, bindingOperation);
createBindingOutput(definition, operation, bindingOperation);
}
else if (operation.getStyle().equals(OperationType.ONE_WAY)) {
createBindingInput(definition, operation, bindingOperation);
}
else if (operation.getStyle().equals(OperationType.NOTIFICATION)) {
createBindingOutput(definition, operation, bindingOperation);
}
else if (operation.getStyle().equals(OperationType.SOLICIT_RESPONSE)) {
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);
bindingOperation.addBindingFault(bindingFault);
}
binding.addBindingOperation(bindingOperation);
}
}
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 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 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());
}
/**
* 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(Definition definition, BindingInput bindingInput, Input input)
throws WSDLException {
bindingInput.setName(input.getName());
}
/**
* 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 sets 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(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());
}
}

View File

@@ -1,30 +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 javax.wsdl.Definition;
import javax.wsdl.WSDLException;
/**
* @author Arjen Poutsma
* @since 1.5.0
*/
public interface ServiceProvider {
void addService(Definition definition) throws WSDLException;
}

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;
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,10 +0,0 @@
<?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

@@ -1,16 +0,0 @@
<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

@@ -1,14 +0,0 @@
<?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

@@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/spring-ws/single/schema"
xmlns="http://www.springframework.org/spring-ws/single/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>