Implemented #SWS-67: Dynamically create WSDL based on schema. Using it in the echo sample.

This commit is contained in:
Arjen Poutsma
2006-12-01 11:42:49 +00:00
parent 1200c45f8f
commit 6f0773bee5
20 changed files with 1912 additions and 82 deletions

View File

@@ -22,11 +22,13 @@ import org.springframework.core.OrderComparator;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.FrameworkServlet;
import org.springframework.web.util.WebUtils;
import org.springframework.ws.EndpointAdapter;
import org.springframework.ws.EndpointExceptionResolver;
import org.springframework.ws.EndpointMapping;
import org.springframework.ws.MessageDispatcher;
import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.wsdl.WsdlDefinition;
/**
* Servlet for simplified dispatching of Web service messages. Delegates to a <code>MessageDispatcher</code> and a
@@ -74,14 +76,10 @@ public class MessageDispatcherServlet extends FrameworkServlet {
*/
public static final String ENDPOINT_MAPPING_BEAN_NAME = "endpointMapping";
/**
* Well-known name for the <code>WebServiceMessageFactory</code> object in the bean factory for this namespace.
*/
/** Well-known name for the <code>WebServiceMessageFactory</code> object in the bean factory for this namespace. */
public static final String WEB_SERVICE_MESSAGE_FACTORY_BEAN_NAME = "messageFactory";
/**
* Well-known name for the <code>MessageDispatcher</code> object in the bean factory for this namespace.
*/
/** Well-known name for the <code>MessageDispatcher</code> object in the bean factory for this namespace. */
public static final String MESSAGE_DISPATCHER_BEAN_NAME = "messageDispatcher";
/**
@@ -90,33 +88,35 @@ public class MessageDispatcherServlet extends FrameworkServlet {
*/
private static final String DEFAULT_STRATEGIES_PATH = "MessageDispatcherServlet.properties";
/** Suffix of a WSDL request uri. */
private static final String WSDL_SUFFIX_NAME = ".wsdl";
private static final Properties defaultStrategies = new Properties();
/**
* Detect all <code>EndpointAdapter</code>s or just expect "endpointAdapter" bean?
*/
/** Detect all <code>EndpointAdapter</code>s or just expect "endpointAdapter" bean? */
private boolean detectAllEndpointAdapters = true;
/**
* Detect all <code>EndpointExceptionResolver</code>s or just expect "endpointExceptionResolver" bean?
*/
/** Detect all <code>EndpointExceptionResolver</code>s or just expect "endpointExceptionResolver" bean? */
private boolean detectAllEndpointExceptionResolvers = true;
/**
* Detect all <code>EndpointMapping</code>s or just expect "endpointMapping" bean?
*/
/** Detect all <code>EndpointMapping</code>s or just expect "endpointMapping" bean? */
private boolean detectAllEndpointMappings = true;
/**
* The <code>MessageEndpointHandlerAdapter</code> used by this servlet.
*/
private MessageEndpointHandlerAdapter handlerAdapter = new MessageEndpointHandlerAdapter();
/** Detect all <code>WsdlDefinition</code>s? */
private boolean detectAllWsdlDefinitions = true;
/**
* The <code>MessageDispatcher</code> used by this servlet.
*/
/** The <code>MessageEndpointHandlerAdapter</code> used by this servlet. */
private MessageEndpointHandlerAdapter messageEndpointHandlerAdapter = new MessageEndpointHandlerAdapter();
/** The <code>WsdlDefinitionHandlerAdapter</code> used by this servlet. */
private WsdlDefinitionHandlerAdapter wsdlDefinitionHandlerAdapter = new WsdlDefinitionHandlerAdapter();
/** The <code>MessageDispatcher</code> used by this servlet. */
private MessageDispatcher messageDispatcher;
/** Keys are beans names, values are <code>WsdlDefinition</code>s. */
private Map wsdlDefinitions;
static {
// Load default strategy implementations from properties file.
// This is currently strictly internal and not meant to be customized
@@ -136,9 +136,7 @@ public class MessageDispatcherServlet extends FrameworkServlet {
}
}
/**
* Returns the <code>MessageDispatcher</code> used by this servlet.
*/
/** Returns the <code>MessageDispatcher</code> used by this servlet. */
protected MessageDispatcher getMessageDispatcher() {
return messageDispatcher;
}
@@ -182,18 +180,56 @@ public class MessageDispatcherServlet extends FrameworkServlet {
this.detectAllEndpointMappings = detectAllEndpointMappings;
}
/**
* Set whether to detect all <code>WsdlDefinition</code> beans in this servlet's context.
* <p/>
* Default is <code>true</code>.
*
* @see org.springframework.ws.wsdl.WsdlDefinition
*/
public void setDetectAllWsdlDefinitions(boolean detectAllWsdlDefinitions) {
this.detectAllWsdlDefinitions = detectAllWsdlDefinitions;
}
protected long getLastModified(HttpServletRequest req) {
return handlerAdapter.getLastModified(req, messageDispatcher);
return messageEndpointHandlerAdapter.getLastModified(req, messageDispatcher);
}
protected void initFrameworkServlet() throws ServletException, BeansException {
initWebServiceMessageFactory();
initMessageDispatcher();
initWsdlDefinitions();
}
protected void doService(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws Exception {
handlerAdapter.handle(httpServletRequest, httpServletResponse, messageDispatcher);
WsdlDefinition definition = getWsdlDefinition(httpServletRequest);
if (definition != null) {
wsdlDefinitionHandlerAdapter.handle(httpServletRequest, httpServletResponse, definition);
}
else {
messageEndpointHandlerAdapter.handle(httpServletRequest, httpServletResponse, messageDispatcher);
}
}
/**
* Determines the <code>WsdlDefinition</code> for a given request, or <code>null</code> if none is found.
* <p/>
* Default implementation checks whether the request method is GET, whether the request uri ends with ".wsdl", and
* if there is a <code>WsdlDefinition</code> with the same name as the filename in the request uri.
*
* @param request the <code>HttpServletRequest</code>
* @return a definition, or <code>null</code>
* @throws Exception in case of errors
*/
protected WsdlDefinition getWsdlDefinition(HttpServletRequest request) throws Exception {
if ("GET".equals(request.getMethod()) && request.getRequestURI().endsWith(WSDL_SUFFIX_NAME)) {
String fileName = WebUtils.extractFilenameFromUrlPath(request.getRequestURI());
return (WsdlDefinition) wsdlDefinitions.get(fileName);
}
else {
return null;
}
}
/**
@@ -365,7 +401,7 @@ public class MessageDispatcherServlet extends FrameworkServlet {
}
}
}
handlerAdapter.setMessageFactory(messageFactory);
messageEndpointHandlerAdapter.setMessageFactory(messageFactory);
}
private void initMessageDispatcher() {
@@ -387,4 +423,12 @@ public class MessageDispatcherServlet extends FrameworkServlet {
initEndpointExceptionResolvers();
}
}
private void initWsdlDefinitions() {
if (detectAllWsdlDefinitions) {
// Find all WsdlDefinitions in the ApplicationContext, incuding ancestor contexts.
wsdlDefinitions = BeanFactoryUtils
.beansOfTypeIncludingAncestors(getWebApplicationContext(), WsdlDefinition.class, true, false);
}
}
}

View File

@@ -0,0 +1,84 @@
/*
* 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;
import javax.xml.transform.Source;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import org.springframework.ws.wsdl.wsdl11.builder.Wsdl11DefinitionBuilder;
/**
* <code>Wsdl11Definition</code> that creates a WSDL definition at runtime, using a {@link Wsdl11DefinitionBuilder}. Can
* be instructed to build abstract or concrete parts of the definition, by setting the <code>buildAbstractPart</code>
* and <code>buildConcretePart</code> properties.
*
* @author Arjen Poutsma
* @see #setBuilder(org.springframework.ws.wsdl.wsdl11.builder.Wsdl11DefinitionBuilder)
* @see #setBuildAbstractPart(boolean)
* @see #setBuildConcretePart(boolean)
*/
public class DynamicWsdl11Definition implements Wsdl11Definition, InitializingBean {
private Wsdl11DefinitionBuilder builder;
private Wsdl11Definition definition;
private boolean buildAbstractPart = true;
private boolean buildConcretePart = true;
public void setBuilder(Wsdl11DefinitionBuilder builder) {
this.builder = builder;
}
/**
* Indicates whether the built definition should contain an abstract part. If set to <code>true</code> (the default)
* the definition will contain types, messages, and portTypes; if <code>false</code>, it will not.
*/
public void setBuildAbstractPart(boolean buildAbstractPart) {
this.buildAbstractPart = buildAbstractPart;
}
/**
* Indicates whether the built definition should contain an concrete part. If set to <code>true</code> (the default)
* the definition will contain bindings, and services; if <code>false</code>, it will not.
*/
public void setBuildConcretePart(boolean buildConcretePart) {
this.buildConcretePart = buildConcretePart;
}
public void afterPropertiesSet() throws Exception {
Assert.notNull(builder, "builder is required");
builder.buildDefinition();
builder.buildImports();
if (buildAbstractPart) {
builder.buildTypes();
builder.buildMessages();
builder.buildPortTypes();
}
if (buildConcretePart) {
builder.buildBindings();
builder.buildServices();
}
definition = builder.getDefinition();
}
public Source getSource() {
return definition.getSource();
}
}

View File

@@ -52,7 +52,7 @@ public class SimpleWsdl11Definition implements Wsdl11Definition, InitializingBea
}
public void afterPropertiesSet() throws Exception {
Assert.notNull(wsdlResource, "wsdlResource is required");
Assert.notNull(wsdlResource, "wsdl is required");
Assert.isTrue(wsdlResource.exists(), "wsdl \"" + wsdlResource + "\" does not exit");
}

View File

@@ -0,0 +1,34 @@
/*
* 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;
import javax.wsdl.WSDLException;
import org.springframework.ws.wsdl.WsdlDefinitionException;
/**
* Subclass of <code>WsdlDefinitionException</code> that wraps <code>WSDLException</code>s.
*
* @author Arjen Poutsma
*/
public class Wsdl4jDefinitionException extends WsdlDefinitionException {
public Wsdl4jDefinitionException(WSDLException ex) {
super(ex.getMessage(), ex);
}
}

View File

@@ -0,0 +1,250 @@
/*
* 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.builder;
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.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.ws.wsdl.wsdl11.Wsdl4jDefinitionException;
/**
* 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>, 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
*/
public abstract class AbstractBindingWsdl4jDefinitionBuilder extends AbstractWsdl4jDefinitionBuilder {
/** The suffix used to create a binding name from a port type name. */
private static final String BINDING_SUFFIX = "Binding";
/** The suffix used to create a binding name from a port type name. */
private static final String PORT_SUFFIX = "Port";
/**
* Creates a <code>Binding</code> for each <code>PortType</code> in the definition, and calls
* <code>populateBinding</code> with it. Creates a <code>BindingOperation</code> for each <code>Operation</code> in
* the port type, a <code>BindingInput</code> for each <code>Input</code> 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 javax.wsdl.Binding
* @see javax.wsdl.extensions.soap.SOAPBinding
* @see #populateBinding(javax.wsdl.Binding,javax.wsdl.PortType)
* @see javax.wsdl.BindingOperation
* @see #populateBindingOperation(javax.wsdl.BindingOperation,javax.wsdl.Operation)
* @see javax.wsdl.BindingInput
* @see #populateBindingInput(javax.wsdl.BindingInput,javax.wsdl.Input)
* @see javax.wsdl.BindingOutput
* @see #populateBindingOutput(javax.wsdl.BindingOutput,javax.wsdl.Output)
* @see javax.wsdl.BindingFault
* @see #populateBindingFault(javax.wsdl.BindingFault,javax.wsdl.Fault)
*/
public void buildBindings(Definition definition) throws WSDLException {
try {
for (Iterator iterator = definition.getPortTypes().values().iterator(); iterator.hasNext();) {
PortType portType = (PortType) iterator.next();
Binding binding = definition.createBinding();
binding.setPortType(portType);
populateBinding(binding, portType);
createBindingOperations(definition, binding, portType);
binding.setUndefined(false);
definition.addBinding(binding);
}
}
catch (WSDLException ex) {
throw new Wsdl4jDefinitionException(ex);
}
}
/**
* Called after the <code>Binding</code> 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 <code>Binding</code> 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() + BINDING_SUFFIX));
}
}
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(bindingOperation, operation);
if (operation.getInput() != null) {
BindingInput bindingInput = definition.createBindingInput();
populateBindingInput(bindingInput, operation.getInput());
bindingOperation.setBindingInput(bindingInput);
}
if (operation.getOutput() != null) {
BindingOutput bindingOutput = definition.createBindingOutput();
populateBindingOutput(bindingOutput, operation.getOutput());
bindingOperation.setBindingOutput(bindingOutput);
}
for (Iterator faultIterator = operation.getFaults().values().iterator(); faultIterator.hasNext();) {
Fault fault = (Fault) faultIterator.next();
BindingFault bindingFault = definition.createBindingFault();
populateBindingFault(bindingFault, fault);
bindingOperation.addBindingFault(bindingFault);
}
binding.addBindingOperation(bindingOperation);
}
}
/**
* Called after the <code>BindingOperation</code> 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());
}
/**
* Called after the <code>BindingInput</code> 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());
}
/**
* Called after the <code>BindingOutput</code> 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());
}
/**
* Called after the <code>BindingFault</code> 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());
}
/**
* Creates a single <code>Service</code>, and calls <code>populateService()</code> with it. Creates a corresponding
* <code>Port</code> for each <code>Binding</code>, which is passed to <code>populatePort()</code>.
*
* @param definition the WSDL4J <code>Definition</code>
* @throws WSDLException in case of errors
* @see javax.wsdl.Service
* @see javax.wsdl.Port
* @see #populatePort(javax.wsdl.Port,javax.wsdl.Binding)
*/
public void buildServices(Definition definition) throws WSDLException {
Service service = definition.createService();
populateService(service);
createPorts(definition, service);
definition.addService(service);
}
/**
* Called after the <code>Binding</code> 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 is empty.
*
* @param service the WSDL4J <code>Service</code>
* @throws WSDLException in case of errors
*/
protected void populateService(Service service) throws WSDLException {
}
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 <code>Port</code> 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/>
* <p/>
* Default implementation sets the port name to the port type name with the suffix <code>Port</code> 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);
}
}
}

View File

@@ -0,0 +1,241 @@
/*
* 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.builder;
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.WSDLException;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.wsdl.extensions.soap.SOAPBinding;
import javax.wsdl.extensions.soap.SOAPBody;
import javax.wsdl.extensions.soap.SOAPOperation;
import javax.xml.namespace.QName;
/**
* Abstract base class for <code>Wsdl11DefinitionBuilder</code> implementations that use WSDL4J and contain a SOAP 1.1
* binding. Requires the <code>locationUri</code> property to be set before use.
*
* @author Arjen Poutsma
* @see #setLocationUri(String)
*/
public abstract class AbstractSoap11Wsdl4jDefinitionBuilder extends AbstractBindingWsdl4jDefinitionBuilder {
private static final String WSDL_SOAP_NAMESPACE_URI = "http://schemas.xmlsoap.org/wsdl/soap/";
private static final String WSDL_SOAP_PREFIX = "soap";
/** The default soap:binding transport attribute value. */
public static final String DEFAULT_TRANSPORT_URI = "http://schemas.xmlsoap.org/soap/http";
private String transportUri = DEFAULT_TRANSPORT_URI;
private String locationUri;
/**
* Sets the value used for the soap:binding transport attribute value.
*
* @see javax.wsdl.extensions.soap.SOAPBinding#setTransportURI(String)
* @see #DEFAULT_TRANSPORT_URI
*/
public void setTransportUri(String transportUri) {
this.transportUri = transportUri;
}
/** Sets the value used for the soap:address location attribute value. */
public void setLocationUri(String locationUri) {
this.locationUri = locationUri;
}
/** Adds the WSDL SOAP namespace to the definition. */
protected void populateDefinition(Definition definition) throws WSDLException {
definition.addNamespace(WSDL_SOAP_PREFIX, WSDL_SOAP_NAMESPACE_URI);
}
/**
* Calls <code>populateBindingInternal()</code>, creates <code>SOAPBinding</code>, and calls
* <code>populateSoapBinding()</code>.
*
* @param binding the WSDL4J <code>Binding</code>
* @param portType the corresponding <code>PortType</code>
* @throws WSDLException in case of errors
* @see javax.wsdl.extensions.soap.SOAPBinding
* @see #populateSoapBinding(javax.wsdl.extensions.soap.SOAPBinding)
*/
protected void populateBinding(Binding binding, PortType portType) throws WSDLException {
super.populateBinding(binding, portType);
SOAPBinding soapBinding = (SOAPBinding) createSoapExtension(Binding.class, "binding");
populateSoapBinding(soapBinding);
binding.addExtensibilityElement(soapBinding);
}
/**
* Called after the <code>SOAPBinding</code> has been created. Default implementation sets the binding style to
* <code>"document"</code>, and set the transport URI to the value set on this builder. Subclasses can override this
* behavior.
*
* @param soapBinding the WSDL4J <code>SOAPBinding</code>
* @throws 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(SOAPBinding soapBinding) throws WSDLException {
soapBinding.setStyle("document");
soapBinding.setTransportURI(transportUri);
}
/**
* Calls <code>getBindingOperationName()</code>, creates a <code>SOAPOperation</code>, and calls
* <code>populateSoapOperation()</code>.
*
* @param bindingOperation the WSDL4J <code>BindingOperation</code>
* @throws WSDLException in case of errors
* @see javax.wsdl.extensions.soap.SOAPOperation
* @see #populateSoapOperation(javax.wsdl.extensions.soap.SOAPOperation)
*/
protected void populateBindingOperation(BindingOperation bindingOperation, Operation operation)
throws WSDLException {
super.populateBindingOperation(bindingOperation, operation);
SOAPOperation soapOperation = (SOAPOperation) createSoapExtension(BindingOperation.class, "operation");
populateSoapOperation(soapOperation);
bindingOperation.addExtensibilityElement(soapOperation);
}
/**
* Called after the <code>SOAPOperation</code> has been created.
* <p/>
* Default implementation set the <code>SOAPAction</code> uri to an empty string.
*
* @param soapOperation the WSDL4J <code>SOAPOperation</code>
* @throws WSDLException in case of errors
* @see javax.wsdl.extensions.soap.SOAPOperation#setSoapActionURI(String)
*/
protected void populateSoapOperation(SOAPOperation soapOperation) throws WSDLException {
soapOperation.setSoapActionURI("");
}
/**
* Creates a <code>SOAPBody</code>, and calls <code>populateSoapBody()</code>.
*
* @param bindingInput the WSDL4J <code>BindingInput</code>
* @throws WSDLException in case of errors
* @see javax.wsdl.extensions.soap.SOAPOperation
* @see #populateSoapBody(javax.wsdl.extensions.soap.SOAPBody)
*/
protected void populateBindingInput(BindingInput bindingInput, Input input) throws WSDLException {
super.populateBindingInput(bindingInput, input);
SOAPBody soapBody = (SOAPBody) createSoapExtension(BindingInput.class, "body");
populateSoapBody(soapBody);
bindingInput.addExtensibilityElement(soapBody);
}
/**
* Creates a <code>SOAPBody</code>, and calls <code>populateSoapBody()</code>.
*
* @param bindingOutput the WSDL4J <code>BindingOutput</code>
* @throws javax.wsdl.WSDLException in case of errors
* @see javax.wsdl.extensions.soap.SOAPOperation
* @see #populateSoapBody(javax.wsdl.extensions.soap.SOAPBody)
*/
protected void populateBindingOutput(BindingOutput bindingOutput, Output output) throws WSDLException {
super.populateBindingOutput(bindingOutput, output);
SOAPBody soapBody = (SOAPBody) createSoapExtension(BindingOutput.class, "body");
populateSoapBody(soapBody);
bindingOutput.addExtensibilityElement(soapBody);
}
/**
* Creates a <code>SOAPBody</code>, and calls <code>populateSoapBody()</code>.
*
* @param bindingFault the WSDL4J <code>BindingFault</code>
* @throws javax.wsdl.WSDLException in case of errors
* @see javax.wsdl.extensions.soap.SOAPOperation
* @see #populateSoapBody(javax.wsdl.extensions.soap.SOAPBody)
*/
protected void populateBindingFault(BindingFault bindingFault, Fault fault) throws WSDLException {
super.populateBindingFault(bindingFault, fault);
SOAPBody soapBody = (SOAPBody) createSoapExtension(BindingOutput.class, "body");
populateSoapBody(soapBody);
bindingFault.addExtensibilityElement(soapBody);
}
/**
* Called after the <code>SOAPBody</code> has been created. 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 javax.wsdl.extensions.soap.SOAPBody#setUse(String)
*/
protected void populateSoapBody(SOAPBody soapBody) throws WSDLException {
soapBody.setUse("literal");
}
/**
* Creates a <code>SOAPAddress</code>, and calls <code>populateSoapAddress()</code>.
*
* @param port the WSDL4J <code>Port</code>
* @throws javax.wsdl.WSDLException in case of errors
* @see javax.wsdl.extensions.soap.SOAPAddress
* @see #populateSoapBody(javax.wsdl.extensions.soap.SOAPBody)
*/
protected void populatePort(Port port, Binding binding) throws WSDLException {
super.populatePort(port, binding);
SOAPAddress soapAddress = (SOAPAddress) createSoapExtension(Port.class, "address");
populateSoapAddress(soapAddress);
port.addExtensibilityElement(soapAddress);
}
/**
* Called after the <code>SOAPAddress</code> 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 javax.wsdl.extensions.soap.SOAPAddress#setLocationURI(String)
* @see #setLocationUri(String)
*/
protected void populateSoapAddress(SOAPAddress soapAddress) throws WSDLException {
soapAddress.setLocationURI(locationUri);
}
/**
* Creates a SOAP extensibility element.
*
* @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,javax.xml.namespace.QName)
*/
protected ExtensibilityElement createSoapExtension(Class parentType, String localName) throws WSDLException {
return createExtension(parentType, new QName(WSDL_SOAP_NAMESPACE_URI, localName));
}
}

View File

@@ -0,0 +1,195 @@
/*
* 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.builder;
import javax.wsdl.Definition;
import javax.wsdl.WSDLException;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.ExtensionRegistry;
import javax.wsdl.factory.WSDLFactory;
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.Wsdl4jDefinition;
import org.springframework.ws.wsdl.wsdl11.Wsdl4jDefinitionException;
/**
* Abstract base class for <code>Wsdl11DefinitionBuilder</code> implementations that use WSDL4J. Creates a base {@link
* Definition}, and passes that to subclass template methods.
*
* @author Arjen Poutsma
*/
public abstract class AbstractWsdl4jDefinitionBuilder implements Wsdl11DefinitionBuilder {
/** Logger available to subclasses. */
protected final Log logger = LogFactory.getLog(getClass());
/** WSDL4J extension registry. Lazily created in <code>createExtension()</code>. */
private ExtensionRegistry extensionRegistry;
/** The WSDL4J <code>Definition</code> created by <code>buildDefinition()</code>. */
private Definition definition;
public final void buildDefinition() throws WsdlDefinitionException {
try {
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
definition = wsdlFactory.newDefinition();
populateDefinition(definition);
}
catch (WSDLException ex) {
throw new Wsdl4jDefinitionException(ex);
}
}
/**
* Called after the <code>Definition</code> has been created, but before any sub-elements are added. Default
* implementation is empty.
*
* @param definition the WSDL4J <code>Definition</code>
* @throws WSDLException in case of errors
* @see #buildDefinition()
*/
protected void populateDefinition(Definition definition) throws WSDLException {
}
public final void buildImports() throws WsdlDefinitionException {
try {
buildImports(definition);
}
catch (WSDLException ex) {
throw new Wsdl4jDefinitionException(ex);
}
}
/**
* Adds imports to the definition.
*
* @param definition the WSDL4J <code>Definition</code>
* @throws WSDLException in case of errors
*/
protected abstract void buildImports(Definition definition) throws WSDLException;
public final void buildTypes() throws WsdlDefinitionException {
try {
buildTypes(definition);
}
catch (WSDLException ex) {
throw new Wsdl4jDefinitionException(ex);
}
}
/**
* Adds types to the definition.
*
* @param definition the WSDL4J <code>Definition</code>
* @throws WSDLException in case of errors
*/
protected abstract void buildTypes(Definition definition) throws WSDLException;
public final void buildMessages() throws WsdlDefinitionException {
try {
buildMessages(definition);
}
catch (WSDLException ex) {
throw new Wsdl4jDefinitionException(ex);
}
}
/**
* Adds messages to the definition.
*
* @param definition the WSDL4J <code>Definition</code>
* @throws WSDLException in case of errors
*/
protected abstract void buildMessages(Definition definition) throws WSDLException;
public final void buildPortTypes() throws WsdlDefinitionException {
try {
buildPortTypes(definition);
}
catch (WSDLException ex) {
throw new Wsdl4jDefinitionException(ex);
}
}
/**
* Adds port types to the definition.
*
* @param definition the WSDL4J <code>Definition</code>
* @throws WSDLException in case of errors
*/
protected abstract void buildPortTypes(Definition definition) throws WSDLException;
public final void buildBindings() throws WsdlDefinitionException {
try {
buildBindings(definition);
}
catch (WSDLException ex) {
throw new Wsdl4jDefinitionException(ex);
}
}
/**
* Adds bindings to the definition.
*
* @param definition the WSDL4J <code>Definition</code>
* @throws WSDLException in case of errors
*/
protected abstract void buildBindings(Definition definition) throws WSDLException;
public final void buildServices() throws WsdlDefinitionException {
try {
buildServices(definition);
}
catch (WSDLException ex) {
throw new Wsdl4jDefinitionException(ex);
}
}
/**
* Adds services to the definition.
*
* @param definition the WSDL4J <code>Definition</code>
* @throws WSDLException in case of errors
*/
protected abstract void buildServices(Definition definition) throws WSDLException;
public final Wsdl11Definition getDefinition() throws WsdlDefinitionException {
return new Wsdl4jDefinition(definition);
}
/**
* Creates a WSDL4J extensibility element.
*
* @param parentType a class object indicating where in the WSDL definition this extension will exist
* @param elementType the qname of the extensibility element
* @return the extensibility element
* @throws WSDLException in case of errors
* @see javax.wsdl.extensions.ExtensionRegistry#createExtension(Class,javax.xml.namespace.QName)
*/
protected ExtensibilityElement createExtension(Class parentType, QName elementType) throws WSDLException {
if (extensionRegistry == null) {
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
extensionRegistry = wsdlFactory.newPopulatedExtensionRegistry();
}
return extensionRegistry.createExtension(parentType, elementType);
}
}

View File

@@ -0,0 +1,89 @@
/*
* 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.builder;
import org.springframework.ws.wsdl.WsdlDefinitionException;
import org.springframework.ws.wsdl.wsdl11.Wsdl11Definition;
/**
* Defines the contract for classes that can create a {@link Wsdl11Definition} at runtime.
* <p/>
* Used by {@link org.springframework.ws.wsdl.wsdl11.DynamicWsdl11Definition} to generate the WSDL based on a schema, a
* class, etc.
*
* @author Arjen Poutsma
*/
public interface Wsdl11DefinitionBuilder {
/**
* Builds a new, empty definition. This method should be called before all others.
*
* @throws WsdlDefinitionException in case of errors
*/
void buildDefinition() throws WsdlDefinitionException;
/**
* Adds imports to the definition.
*
* @throws WsdlDefinitionException in case of errors
*/
void buildImports() throws WsdlDefinitionException;
/**
* Adds types to the definition.
*
* @throws WsdlDefinitionException in case of errors
*/
void buildTypes() throws WsdlDefinitionException;
/**
* Adds messages to the definition.
*
* @throws WsdlDefinitionException in case of errors
*/
void buildMessages() throws WsdlDefinitionException;
/**
* Adds portTypes to the definition.
*
* @throws WsdlDefinitionException in case of errors
*/
void buildPortTypes() throws WsdlDefinitionException;
/**
* Adds bindings to the definition.
*
* @throws WsdlDefinitionException in case of errors
*/
void buildBindings() throws WsdlDefinitionException;
/**
* Adds services to the definition.
*
* @throws WsdlDefinitionException in case of errors
*/
void buildServices() throws WsdlDefinitionException;
/**
* Returns the built <code>Wsdl11Definition</code>.
*
* @return the WSDL definition, or <code>null</code> if {@link #buildDefinition()} has not been called
* @throws WsdlDefinitionException in case of errors
*/
Wsdl11Definition getDefinition() throws WsdlDefinitionException;
}

View File

@@ -0,0 +1,404 @@
/*
* 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.builder;
import java.io.IOException;
import java.util.Iterator;
import javax.wsdl.Definition;
import javax.wsdl.Input;
import javax.wsdl.Message;
import javax.wsdl.Operation;
import javax.wsdl.Output;
import javax.wsdl.Part;
import javax.wsdl.PortType;
import javax.wsdl.Service;
import javax.wsdl.Types;
import javax.wsdl.WSDLException;
import javax.wsdl.extensions.schema.Schema;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.springframework.beans.factory.InitializingBean;
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.NodeList;
import org.xml.sax.SAXException;
/**
* Builds a <code>WsdlDefinition</code> with a SOAP 1.1 binding based on an XSD schema. This builder iterates over all
* <code>element</code>s found in the schema, and creates a <code>message</code> for those elements that end with the
* request or response suffix. It combines these messages into <code>operation</code>s, and builds a
* <code>portType</code> based on the operations. The schema itself is inlined in a <code>types</code> block.
* <p/>
* Requires the <code>schema</code> and <code>portTypeName</code> properties to be set.
*
* @author Arjen Poutsma
* @see #setSchema(org.springframework.core.io.Resource)
* @see #setPortTypeName(String)
* @see #setRequestSuffix(String)
* @see #setResponseSuffix(String)
*/
public class XsdBasedSoap11Wsdl4jDefinitionBuilder extends AbstractSoap11Wsdl4jDefinitionBuilder
implements InitializingBean {
/** The schema namespace URI. */
private static final String SCHEMA_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema";
/** 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 prefix used to register the schema namespace in the WSDL. */
public static final String DEFAULT_SCHEMA_PREFIX = "schema";
/** The default prefix used to register the target namespace in the WSDL. */
public static final String DEFAULT_PREFIX = "tns";
/** The suffix used to create a service name from a port type name. */
public static final String SERVICE_SUFFIX = "Service";
private Resource schema;
private Element schemaElement;
private String targetNamespace;
private String portTypeName;
private String schemaPrefix = DEFAULT_SCHEMA_PREFIX;
private String prefix = DEFAULT_PREFIX;
private String requestSuffix = DEFAULT_REQUEST_SUFFIX;
private String responseSuffix = DEFAULT_RESPONSE_SUFFIX;
/**
* Sets the suffix used to detect request elements in the schema.
*
* @see #DEFAULT_REQUEST_SUFFIX
*/
public void setRequestSuffix(String requestSuffix) {
this.requestSuffix = requestSuffix;
}
/**
* Sets the suffix used to detect response elements in the schema.
*
* @see #DEFAULT_RESPONSE_SUFFIX
*/
public void setResponseSuffix(String responseSuffix) {
this.responseSuffix = responseSuffix;
}
/** Sets the port type name used for this definition. Required. */
public void setPortTypeName(String portTypeName) {
this.portTypeName = portTypeName;
}
/** Sets the target namespace used for this definition. */
public void setTargetNamespace(String targetNamespace) {
this.targetNamespace = targetNamespace;
}
/**
* Sets the prefix used to declare the schema target namespace.
*
* @see #DEFAULT_SCHEMA_PREFIX
*/
public void setSchemaPrefix(String schemaPrefix) {
this.schemaPrefix = schemaPrefix;
}
/**
* Sets the prefix used to declare the target namespace.
*
* @see #DEFAULT_PREFIX
*/
public void setPrefix(String prefix) {
this.prefix = prefix;
}
/** Sets the XSD schema to use for generating the WSDL. */
public void setSchema(Resource schema) {
Assert.notNull(schema, "schema must not be empty or null");
Assert.isTrue(schema.exists(), "schema \"" + schema + "\" does not exit");
this.schema = schema;
}
public final void afterPropertiesSet() throws IOException, ParserConfigurationException, SAXException {
Assert.notNull(schema, "schema is required");
Assert.notNull(portTypeName, "portTypeName is required");
parseSchema();
}
private void parseSchema() throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document schemaDocument = documentBuilder.parse(SaxUtils.createInputSource(schema));
schemaElement = schemaDocument.getDocumentElement();
Assert.isTrue("schema".equals(schemaElement.getLocalName()),
"schema document root element has invalid local name : [" + schemaElement.getLocalName() +
"] instead of [schema]");
Assert.isTrue(SCHEMA_NAMESPACE_URI.equals(schemaElement.getNamespaceURI()),
"schema document root element has invalid namespace uri: [" + schemaElement.getNamespaceURI() +
"] instead of [" + SCHEMA_NAMESPACE_URI + "]");
String schemaTargetNamespace = getSchemaTargetNamespace();
Assert.hasLength(schemaTargetNamespace, "schema document has no targetNamespace");
if (!StringUtils.hasLength(targetNamespace)) {
targetNamespace = schemaTargetNamespace;
}
}
private String getSchemaTargetNamespace() {
return schemaElement.getAttribute("targetNamespace");
}
/** Adds the target namespace and schema namespace to the definition. */
protected void populateDefinition(Definition definition) throws WSDLException {
super.populateDefinition(definition);
definition.setTargetNamespace(targetNamespace);
definition.addNamespace(schemaPrefix, getSchemaTargetNamespace());
if (!targetNamespace.equals(getSchemaTargetNamespace())) {
definition.addNamespace(prefix, targetNamespace);
}
}
/** Does nothing. */
protected void buildImports(Definition definition) throws WSDLException {
}
/**
* Creates a <code>Types</code> object that is populated with the types found in the schema.
*
* @param definition the WSDL4J <code>Definition</code>
* @throws WSDLException in case of errors
*/
protected void buildTypes(Definition definition) throws WSDLException {
Types types = definition.createTypes();
Schema schema = (Schema) createExtension(Types.class, QNameUtils.getQNameForNode(schemaElement));
schema.setElement(schemaElement);
types.addExtensibilityElement(schema);
definition.setTypes(types);
}
/**
* Creates messages for each element found in the schema for which <code>isRequestMessage()</code> or
* <code>isResponseMessage()</code> is <code>true</code>.
*
* @param definition the WSDL4J <code>Definition</code>
* @throws WSDLException in case of errors
* @see #isRequestMessage(javax.xml.namespace.QName)
* @see #isResponseMessage(javax.xml.namespace.QName)
*/
protected void buildMessages(Definition definition) throws WSDLException {
NodeList elements = schemaElement.getElementsByTagNameNS(SCHEMA_NAMESPACE_URI, "element");
for (int i = 0; i < elements.getLength(); i++) {
Element element = (Element) elements.item(i);
QName elementName = getSchemaElementName(element);
if (isRequestMessage(elementName) || isResponseMessage(elementName)) {
Message message = definition.createMessage();
populateMessage(message, element);
Part part = definition.createPart();
populatePart(part, elementName);
message.addPart(part);
message.setUndefined(false);
definition.addMessage(message);
}
}
}
/**
* Indicates whether the given name name should be included as request <code>Message</code> in the definition.
* Default implementation checks whether the local part ends with the request suffix.
*
* @param name the name of the element elligable for being a message
* @return <code>true</code> if to be included as message; <code>false</code> otherwise
* @see #setRequestSuffix(String)
*/
protected boolean isRequestMessage(QName name) {
return name.getLocalPart().endsWith(requestSuffix);
}
/**
* Indicates whether the given name should be included as <code>Message</code> in the definition. Default
* implementation checks whether the local part ends with the response suffix.
*
* @param name the name of the element elligable for being a message
* @return <code>true</code> if to be included as message; <code>false</code> otherwise
* @see #setResponseSuffix(String)
*/
protected boolean isResponseMessage(QName name) {
return name.getLocalPart().endsWith(responseSuffix);
}
/**
* Called after the <code>Message</code> has been created.
* <p/>
* Default implementation sets the name of the message to the element name.
*
* @param message the WSDL4J <code>Message</code>
* @param element the element
* @throws WSDLException in case of errors
*/
protected void populateMessage(Message message, Element element) {
message.setQName(new QName(targetNamespace, element.getAttribute("name")));
}
/**
* Called after the <code>Part</code> has been created.
* <p/>
* Default implementation sets the element name of the part.
*
* @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(Part part, QName elementName) {
part.setElementName(elementName);
part.setName(elementName.getLocalPart());
}
protected void buildPortTypes(Definition definition) throws WSDLException {
PortType portType = definition.createPortType();
populatePortType(portType);
createOperations(definition, portType);
portType.setUndefined(false);
definition.addPortType(portType);
}
/**
* Called after the <code>PortType</code> 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(PortType portType) throws WSDLException {
portType.setQName(new QName(targetNamespace, portTypeName));
}
private void createOperations(Definition definition, PortType portType) throws WSDLException {
for (Iterator messageIterator = definition.getMessages().values().iterator(); messageIterator.hasNext();) {
Message message = (Message) messageIterator.next();
for (Iterator partIterator = message.getParts().values().iterator(); partIterator.hasNext();) {
Part part = (Part) partIterator.next();
if (isRequestMessage(part.getElementName())) {
Message responseMessage = definition.getMessage(getResponseMessageName(message.getQName()));
Operation operation = definition.createOperation();
populateOperation(operation, message, responseMessage);
if (message != null) {
Input input = definition.createInput();
input.setMessage(message);
input.setName(message.getQName().getLocalPart());
operation.setInput(input);
}
if (responseMessage != null) {
Output output = definition.createOutput();
output.setMessage(responseMessage);
output.setName(responseMessage.getQName().getLocalPart());
operation.setOutput(output);
}
operation.setUndefined(false);
portType.addOperation(operation);
}
}
}
}
/**
* Given an request message name, return the corresponding response message name.
* <p/>
* Default implementation removes the request suffix, and appends the response suffix.
*
* @param requestMessageName the name of the request message
* @return the name of the corresponding response message, or null
*/
protected QName getResponseMessageName(QName requestMessageName) {
String localPart = requestMessageName.getLocalPart();
if (localPart.endsWith(requestSuffix)) {
String prefix = localPart.substring(0, localPart.length() - requestSuffix.length());
return new QName(requestMessageName.getNamespaceURI(), prefix + responseSuffix);
}
else {
return null;
}
}
/**
* Called after the <code>Operation</code> has been created.
* <p/>
* Default implementation sets the name of the operation to name of the messages, without suffix.
*
* @param operation the WSDL4J <code>Operation</code>
* @param requestMessage the WSDL4J request <code>Message</code>
* @param responseMessage the WSDL4J response <code>Message</code>
* @throws WSDLException in case of errors
* @see #setPortTypeName(String)
*/
protected void populateOperation(Operation operation, Message requestMessage, Message responseMessage)
throws WSDLException {
String localPart = requestMessage.getQName().getLocalPart();
String operationName = null;
if (localPart.endsWith(requestSuffix)) {
operationName = localPart.substring(0, localPart.length() - requestSuffix.length());
}
else {
localPart = responseMessage.getQName().getLocalPart();
if (localPart.endsWith(responseSuffix)) {
operationName = localPart.substring(0, localPart.length() - responseSuffix.length());
operationName = localPart;
}
}
operation.setName(operationName);
}
/** Sets the name of the service to the name of the port type, with "Service" appended to it. */
protected void populateService(Service service) throws WSDLException {
service.setQName(new QName(targetNamespace, portTypeName + SERVICE_SUFFIX));
}
/**
* Returns the qualified name of the element. This is a combination of schema target namespace and the value of the
* "name" attribute value.
*
* @param element an element
* @return the value of the name attribute
*/
private QName getSchemaElementName(Element element) {
String attributeValue = element.getAttribute("name");
if (StringUtils.hasLength(attributeValue)) {
return new QName(getSchemaTargetNamespace(), attributeValue);
}
else {
return null;
}
}
}

View File

@@ -0,0 +1,5 @@
<html>
<body>
Provides a strategy for WSDL building. Used by DynamicWsdl11Definition to generate WSDL definitions at runtime.
</body>
</html>

View File

@@ -1,5 +1,5 @@
<html>
<body>
Contains interfaces specific to WSDL 1.1.
Contains interfaces and classes specific to WSDL 1.1.
</body>
</html>

View File

@@ -1,11 +1,19 @@
package org.springframework.ws.transport.http;
import java.io.ByteArrayInputStream;
import java.util.List;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import junit.framework.TestCase;
import org.custommonkey.xmlunit.XMLTestCase;
import org.custommonkey.xmlunit.XMLUnit;
import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.core.io.ClassPathResource;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletConfig;
import org.springframework.mock.web.MockServletContext;
import org.springframework.web.context.support.StaticWebApplicationContext;
@@ -13,8 +21,10 @@ import org.springframework.ws.MessageDispatcher;
import org.springframework.ws.endpoint.PayloadEndpointAdapter;
import org.springframework.ws.endpoint.mapping.PayloadRootQNameEndpointMapping;
import org.springframework.ws.soap.endpoint.SimpleSoapExceptionResolver;
import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition;
import org.w3c.dom.Document;
public class MessageDispatcherServletTest extends TestCase {
public class MessageDispatcherServletTest extends XMLTestCase {
private ServletConfig config;
@@ -70,6 +80,21 @@ public class MessageDispatcherServletTest extends TestCase {
assertStrategies(SimpleSoapExceptionResolver.class, messageDispatcher.getEndpointExceptionResolvers());
}
public void testDetectWsdlDefinitions() throws Exception {
servlet.setContextClass(WsdlDefinitionWebApplicationContext.class);
servlet.init(config);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/definition.wsdl");
MockHttpServletResponse response = new MockHttpServletResponse();
servlet.service(request, response);
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document result = documentBuilder.parse(new ByteArrayInputStream(response.getContentAsByteArray()));
Document expected = documentBuilder.parse(getClass().getResourceAsStream("wsdl11-input.wsdl"));
XMLUnit.setIgnoreWhitespace(true);
assertXMLEqual("Invalid WSDL written", expected, result);
}
private static class DetectWebApplicationContext extends StaticWebApplicationContext {
public void refresh() throws BeansException, IllegalStateException {
@@ -104,4 +129,14 @@ public class MessageDispatcherServletTest extends TestCase {
super.refresh();
}
}
private static class WsdlDefinitionWebApplicationContext extends StaticWebApplicationContext {
public void refresh() throws BeansException, IllegalStateException {
MutablePropertyValues mpv = new MutablePropertyValues();
mpv.addPropertyValue("wsdl", new ClassPathResource("wsdl11-input.wsdl", getClass()));
registerSingleton("definition", SimpleWsdl11Definition.class, mpv);
super.refresh();
}
}
}

View File

@@ -0,0 +1,76 @@
/*
* 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;
import junit.framework.TestCase;
import org.easymock.MockControl;
import org.springframework.ws.wsdl.wsdl11.builder.Wsdl11DefinitionBuilder;
public class DynamicWsdl11DefinitionTest extends TestCase {
private DynamicWsdl11Definition definition;
private MockControl builderControl;
private Wsdl11DefinitionBuilder builderMock;
protected void setUp() throws Exception {
definition = new DynamicWsdl11Definition();
builderControl = MockControl.createControl(Wsdl11DefinitionBuilder.class);
builderMock = (Wsdl11DefinitionBuilder) builderControl.getMock();
definition.setBuilder(builderMock);
}
public void testComplete() throws Exception {
builderMock.buildDefinition();
builderMock.buildImports();
builderMock.buildTypes();
builderMock.buildMessages();
builderMock.buildPortTypes();
builderMock.buildBindings();
builderMock.buildServices();
builderControl.expectAndReturn(builderMock.getDefinition(), null);
builderControl.replay();
definition.afterPropertiesSet();
builderControl.verify();
}
public void testAbstract() throws Exception {
definition.setBuildConcretePart(false);
builderMock.buildDefinition();
builderMock.buildImports();
builderMock.buildTypes();
builderMock.buildMessages();
builderMock.buildPortTypes();
builderControl.expectAndReturn(builderMock.getDefinition(), null);
builderControl.replay();
definition.afterPropertiesSet();
builderControl.verify();
}
public void testConcrete() throws Exception {
definition.setBuildAbstractPart(false);
builderMock.buildDefinition();
builderMock.buildImports();
builderMock.buildBindings();
builderMock.buildServices();
builderControl.expectAndReturn(builderMock.getDefinition(), null);
builderControl.replay();
definition.afterPropertiesSet();
builderControl.verify();
}
}

View File

@@ -0,0 +1,80 @@
/*
* 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.builder;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import org.custommonkey.xmlunit.XMLTestCase;
import org.custommonkey.xmlunit.XMLUnit;
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.wsdl.wsdl11.Wsdl11Definition;
import org.w3c.dom.Document;
public class XsdBasedSoap11Wsdl4jDefinitionBuilderTest extends XMLTestCase {
private XsdBasedSoap11Wsdl4jDefinitionBuilder builder;
private Transformer transformer;
protected void setUp() throws Exception {
builder = new XsdBasedSoap11Wsdl4jDefinitionBuilder();
builder.setSchema(new ClassPathResource("schema.xsd", getClass()));
builder.setPortTypeName("Airline");
builder.setTargetNamespace("http://www.springframework.org/spring-ws/wsdl/definitions");
builder.setLocationUri("http://localhost:8080/");
builder.afterPropertiesSet();
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformer = transformerFactory.newTransformer();
}
public void testNonExistingSchema() throws Exception {
try {
builder.setSchema(new ClassPathResource("bla"));
fail("IllegalArgumentException expected");
}
catch (IllegalArgumentException ex) {
// expected
}
}
public void testBuilder() throws Exception {
builder.buildDefinition();
builder.buildDefinition();
builder.buildImports();
builder.buildTypes();
builder.buildMessages();
builder.buildPortTypes();
builder.buildBindings();
builder.buildServices();
Wsdl11Definition definition = builder.getDefinition();
DOMResult domResult = new DOMResult();
transformer.transform(definition.getSource(), domResult);
Document result = (Document) domResult.getNode();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document expected = documentBuilder.parse(getClass().getResourceAsStream("expected.wsdl"));
XMLUnit.setIgnoreWhitespace(true);
assertXMLEqual("Invalid WSDL built", expected, result);
}
}

View File

@@ -0,0 +1,204 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:schema="http://www.springframework.org/spring-ws/samples/airline/schemas"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.springframework.org/spring-ws/wsdl/definitions"
targetNamespace="http://www.springframework.org/spring-ws/wsdl/definitions">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.springframework.org/spring-ws/samples/airline/schemas"
elementFormDefault="qualified"
targetNamespace="http://www.springframework.org/spring-ws/samples/airline/schemas">
<element name="GetFlightsRequest">
<complexType>
<all>
<element name="from" type="tns:AirportCode"/>
<element name="to" type="tns:AirportCode"/>
<element name="departureDate" type="date"/>
<element minOccurs="0" name="serviceClass" type="tns:ServiceClass"/>
</all>
</complexType>
</element>
<element name="GetFlightsResponse">
<complexType>
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="flight" type="tns:Flight"/>
</sequence>
</complexType>
</element>
<element name="BookFlightRequest">
<complexType>
<all>
<element name="flightNumber" type="tns:FlightNumber"/>
<element name="departureTime" type="dateTime"/>
<element name="passengers">
<complexType>
<choice maxOccurs="9">
<element name="passenger" type="tns:Name"/>
<element name="username" type="tns:FrequentFlyerUsername"/>
</choice>
</complexType>
</element>
</all>
</complexType>
</element>
<element name="BookFlightResponse" type="tns:Ticket"/>
<element name="GetFrequentFlyerMileageRequest"/>
<element name="GetFrequentFlyerMileageResponse" type="int"/>
<complexType name="Flight">
<sequence>
<element name="number" type="tns:FlightNumber"/>
<element name="departureTime" type="dateTime"/>
<element name="from" type="tns:Airport"/>
<element name="arrivalTime" type="dateTime"/>
<element name="to" type="tns:Airport"/>
<element name="serviceClass" type="tns:ServiceClass"/>
</sequence>
</complexType>
<simpleType name="FlightNumber">
<restriction base="string">
<pattern value="[A-Z][A-Z][0-9][0-9][0-9][0-9]"/>
</restriction>
</simpleType>
<complexType name="Name">
<sequence>
<element name="first" type="string"/>
<element name="last" type="string"/>
</sequence>
</complexType>
<simpleType name="FrequentFlyerUsername">
<restriction base="string"/>
</simpleType>
<complexType name="Airport">
<all>
<element name="code" type="tns:AirportCode"/>
<element name="name" type="string"/>
<element name="city" type="string"/>
</all>
</complexType>
<simpleType name="AirportCode">
<restriction base="string">
<pattern value="[A-Z][A-Z][A-Z]"/>
</restriction>
</simpleType>
<complexType name="Ticket">
<all>
<element name="id" type="long"/>
<element name="issueDate" type="date"/>
<element name="passengers">
<complexType>
<sequence>
<element maxOccurs="9" name="passenger" type="tns:Name"/>
</sequence>
</complexType>
</element>
<element name="flight" type="tns:Flight"/>
</all>
</complexType>
<simpleType name="ServiceClass">
<restriction base="NCName">
<enumeration value="economy"/>
<enumeration value="business"/>
<enumeration value="first"/>
</restriction>
</simpleType>
</schema>
</wsdl:types>
<wsdl:message name="GetFrequentFlyerMileageResponse">
<wsdl:part element="schema:GetFrequentFlyerMileageResponse" name="GetFrequentFlyerMileageResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="BookFlightResponse">
<wsdl:part element="schema:BookFlightResponse" name="BookFlightResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="GetFlightsRequest">
<wsdl:part element="schema:GetFlightsRequest" name="GetFlightsRequest">
</wsdl:part>
</wsdl:message>
<wsdl:message name="GetFrequentFlyerMileageRequest">
<wsdl:part element="schema:GetFrequentFlyerMileageRequest" name="GetFrequentFlyerMileageRequest">
</wsdl:part>
</wsdl:message>
<wsdl:message name="GetFlightsResponse">
<wsdl:part element="schema:GetFlightsResponse" name="GetFlightsResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="BookFlightRequest">
<wsdl:part element="schema:BookFlightRequest" name="BookFlightRequest">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="Airline">
<wsdl:operation name="GetFlights">
<wsdl:input message="tns:GetFlightsRequest" name="GetFlightsRequest">
</wsdl:input>
<wsdl:output message="tns:GetFlightsResponse" name="GetFlightsResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetFrequentFlyerMileage">
<wsdl:input message="tns:GetFrequentFlyerMileageRequest" name="GetFrequentFlyerMileageRequest">
</wsdl:input>
<wsdl:output message="tns:GetFrequentFlyerMileageResponse" name="GetFrequentFlyerMileageResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="BookFlight">
<wsdl:input message="tns:BookFlightRequest" name="BookFlightRequest">
</wsdl:input>
<wsdl:output message="tns:BookFlightResponse" name="BookFlightResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="AirlineBinding" type="tns:Airline">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetFlights">
<soap:operation soapAction=""/>
<wsdl:input name="GetFlightsRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="GetFlightsResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetFrequentFlyerMileage">
<soap:operation soapAction=""/>
<wsdl:input name="GetFrequentFlyerMileageRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="GetFrequentFlyerMileageResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="BookFlight">
<soap:operation soapAction=""/>
<wsdl:input name="BookFlightRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="BookFlightResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="AirlineService">
<wsdl:port binding="tns:AirlineBinding" name="AirlinePort">
<soap:address location="http://localhost:8080/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

View File

@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/spring-ws/samples/airline/schemas"
xmlns:tns="http://www.springframework.org/spring-ws/samples/airline/schemas"
elementFormDefault="qualified">
<element name="GetFlightsRequest">
<complexType>
<all>
<element name="from" type="tns:AirportCode"/>
<element name="to" type="tns:AirportCode"/>
<element name="departureDate" type="date"/>
<element name="serviceClass" type="tns:ServiceClass" minOccurs="0"/>
</all>
</complexType>
</element>
<element name="GetFlightsResponse">
<complexType>
<sequence>
<element name="flight" type="tns:Flight" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
<element name="BookFlightRequest">
<complexType>
<all>
<element name="flightNumber" type="tns:FlightNumber"/>
<element name="departureTime" type="dateTime"/>
<element name="passengers">
<complexType>
<choice maxOccurs="9">
<element name="passenger" type="tns:Name"/>
<element name="username" type="tns:FrequentFlyerUsername"/>
</choice>
</complexType>
</element>
</all>
</complexType>
</element>
<element name="BookFlightResponse" type="tns:Ticket"/>
<element name="GetFrequentFlyerMileageRequest"/>
<element name="GetFrequentFlyerMileageResponse" type="int"/>
<complexType name="Flight">
<sequence>
<element name="number" type="tns:FlightNumber"/>
<element name="departureTime" type="dateTime"/>
<element name="from" type="tns:Airport"/>
<element name="arrivalTime" type="dateTime"/>
<element name="to" type="tns:Airport"/>
<element name="serviceClass" type="tns:ServiceClass"/>
</sequence>
</complexType>
<simpleType name="FlightNumber">
<restriction base="string">
<pattern value="[A-Z][A-Z][0-9][0-9][0-9][0-9]"/>
</restriction>
</simpleType>
<complexType name="Name">
<sequence>
<element name="first" type="string"/>
<element name="last" type="string"/>
</sequence>
</complexType>
<simpleType name="FrequentFlyerUsername">
<restriction base="string"/>
</simpleType>
<complexType name="Airport">
<all>
<element name="code" type="tns:AirportCode"/>
<element name="name" type="string"/>
<element name="city" type="string"/>
</all>
</complexType>
<simpleType name="AirportCode">
<restriction base="string">
<pattern value="[A-Z][A-Z][A-Z]"/>
</restriction>
</simpleType>
<complexType name="Ticket">
<all>
<element name="id" type="long"/>
<element name="issueDate" type="date"/>
<element name="passengers">
<complexType>
<sequence>
<element name="passenger" type="tns:Name" maxOccurs="9"/>
</sequence>
</complexType>
</element>
<element name="flight" type="tns:Flight"/>
</all>
</complexType>
<simpleType name="ServiceClass">
<restriction base="NCName">
<enumeration value="economy"/>
<enumeration value="business"/>
<enumeration value="first"/>
</restriction>
</simpleType>
</schema>

View File

@@ -28,7 +28,7 @@
This interceptor validates both incoming and outgoing message contents according to the 'echo.xsd' XML
Schema file.
</description>
<property name="schema" value="/echo.xsd"/>
<property name="schema" value="/WEB-INF/echo.xsd"/>
<property name="validateRequest" value="true"/>
<property name="validateResponse" value="true"/>
</bean>
@@ -46,6 +46,25 @@
<property name="echoService" ref="echoService"/>
</bean>
<bean id="echo" class="org.springframework.ws.wsdl.wsdl11.DynamicWsdl11Definition">
<description>
This bean definition represents a WSDL definition that is generated at runtime, based on the builder defined
below. It can be retrieved by going to /echo/echo.wsdl (i.e. the bean name corresponds to the filename).
</description>
<property name="builder">
<description>
The builder creates a WSDL from the 'echo.xsd' schema. It detects all elements that ends with 'Request',
finds corresponding 'Response' messages, and creates an operation based on that. All operations are put
in a portType with name 'Echo', and binding and service are created.
</description>
<bean class="org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder">
<property name="schema" value="/WEB-INF/echo.xsd"/>
<property name="portTypeName" value="Echo"/>
<property name="locationUri" value="http://localhost:8080/echo/services"/>
</bean>
</property>
</bean>
<bean id="echoService" class="org.springframework.ws.samples.echo.service.impl.EchoServiceImpl">
<description>
This bean is our "business" service.

View File

@@ -19,7 +19,7 @@
<!-- We map all service request to the springws servlet. -->
<servlet-mapping>
<servlet-name>spring-ws</servlet-name>
<url-pattern>/services</url-pattern>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<mime-mapping>

View File

@@ -1,48 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://www.springframework.org/spring-ws/samples/echo"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/spring-ws/samples/echo">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.springframework.org/spring-ws/samples/echo/schemas"
schemaLocation="echo.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="echoRequest">
<wsdl:part name="echoString" element="tns:echoRequest"/>
</wsdl:message>
<wsdl:message name="echoResponse">
<wsdl:part name="theEcho" element="tns:echoResponse"/>
</wsdl:message>
<wsdl:portType name="TestServicePortType">
<wsdl:operation name="echo">
<wsdl:input message="tns:echoRequest" name="echoRequest"/>
<wsdl:output message="tns:echoResponse" name="echoResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TestServiceHttpBinding" type="tns:TestServicePortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="echo">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="echoRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="echoResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TestService">
<wsdl:port binding="tns:TestServiceHttpBinding" name="TestServiceHttpPort">
<wsdlsoap:address location="http://localhost:8080/echo/services"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>