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

@@ -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,89 +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.provider;
import javax.wsdl.Definition;
import javax.wsdl.Message;
import javax.wsdl.Part;
import javax.wsdl.Types;
import javax.wsdl.extensions.schema.Schema;
import javax.wsdl.factory.WSDLFactory;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import junit.framework.TestCase;
import org.w3c.dom.Document;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.xml.sax.SaxUtils;
public class DefaultMessagesProviderTest extends TestCase {
private DefaultMessagesProvider provider;
private Definition definition;
private DocumentBuilder documentBuilder;
protected void setUp() throws Exception {
provider = new DefaultMessagesProvider();
WSDLFactory factory = WSDLFactory.newInstance();
definition = factory.newDefinition();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
documentBuilder = documentBuilderFactory.newDocumentBuilder();
}
public void testAddMessages() throws Exception {
String definitionNamespace = "http://springframework.org/spring-ws";
definition.addNamespace("tns", definitionNamespace);
definition.setTargetNamespace(definitionNamespace);
String schemaNamespace = "http://www.springframework.org/spring-ws/schema";
definition.addNamespace("schema", schemaNamespace);
Resource resource = new ClassPathResource("schema.xsd", getClass());
Document schemaDocument = documentBuilder.parse(SaxUtils.createInputSource(resource));
Types types = definition.createTypes();
definition.setTypes(types);
Schema schema = (Schema) definition.getExtensionRegistry()
.createExtension(Types.class, new QName("http://www.w3.org/2001/XMLSchema", "schema"));
types.addExtensibilityElement(schema);
schema.setElement(schemaDocument.getDocumentElement());
provider.addMessages(definition);
Message message = definition.getMessage(new QName(definitionNamespace, "GetOrderRequest"));
assertNotNull("Message not created", message);
Part part = message.getPart("GetOrderRequest");
assertNotNull("Part not created", part);
assertEquals("Invalid element on part", new QName(schemaNamespace, "GetOrderRequest"), part.getElementName());
message = definition.getMessage(new QName(definitionNamespace, "GetOrderResponse"));
assertNotNull("Message not created", message);
part = message.getPart("GetOrderResponse");
assertNotNull("Part not created", part);
assertEquals("Invalid element on part", new QName(schemaNamespace, "GetOrderResponse"), part.getElementName());
message = definition.getMessage(new QName(definitionNamespace, "GetOrderFault"));
assertNotNull("Message not created", message);
part = message.getPart("GetOrderFault");
assertNotNull("Part not created", part);
assertEquals("Invalid element on part", new QName(schemaNamespace, "GetOrderFault"), part.getElementName());
}
}

View File

@@ -1,92 +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.provider;
import javax.wsdl.Definition;
import javax.wsdl.Types;
import javax.wsdl.extensions.schema.Schema;
import javax.wsdl.factory.WSDLFactory;
import junit.framework.TestCase;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.xml.xsd.SimpleXsdSchema;
import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection;
public class InliningXsdSchemaTypesProviderTest extends TestCase {
private InliningXsdSchemaTypesProvider provider;
private Definition definition;
protected void setUp() throws Exception {
provider = new InliningXsdSchemaTypesProvider();
WSDLFactory factory = WSDLFactory.newInstance();
definition = factory.newDefinition();
}
public void testSingle() throws Exception {
String definitionNamespace = "http://springframework.org/spring-ws";
definition.addNamespace("tns", definitionNamespace);
definition.setTargetNamespace(definitionNamespace);
String schemaNamespace = "http://www.springframework.org/spring-ws/schema";
definition.addNamespace("schema", schemaNamespace);
Resource resource = new ClassPathResource("schema.xsd", getClass());
SimpleXsdSchema schema = new SimpleXsdSchema(resource);
schema.afterPropertiesSet();
provider.setSchema(schema);
provider.addTypes(definition);
Types types = definition.getTypes();
assertNotNull("No types created", types);
assertEquals("Invalid amount of schemas", 1, types.getExtensibilityElements().size());
Schema wsdlSchema = (Schema) types.getExtensibilityElements().get(0);
assertNotNull("No element defined", wsdlSchema.getElement());
}
public void testComplex() throws Exception {
String definitionNamespace = "http://springframework.org/spring-ws";
definition.addNamespace("tns", definitionNamespace);
definition.setTargetNamespace(definitionNamespace);
String schemaNamespace = "http://www.springframework.org/spring-ws/schema";
definition.addNamespace("schema", schemaNamespace);
Resource resource = new ClassPathResource("A.xsd", getClass());
CommonsXsdSchemaCollection collection = new CommonsXsdSchemaCollection(new Resource[]{resource});
collection.setInline(true);
collection.afterPropertiesSet();
provider.setSchemaCollection(collection);
provider.addTypes(definition);
Types types = definition.getTypes();
assertNotNull("No types created", types);
assertEquals("Invalid amount of schemas", 2, types.getExtensibilityElements().size());
Schema wsdlSchema = (Schema) types.getExtensibilityElements().get(0);
assertNotNull("No element defined", wsdlSchema.getElement());
wsdlSchema = (Schema) types.getExtensibilityElements().get(1);
assertNotNull("No element defined", wsdlSchema.getElement());
}
}

View File

@@ -1,142 +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.provider;
import java.util.Properties;
import javax.wsdl.Binding;
import javax.wsdl.BindingFault;
import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
import javax.wsdl.BindingOutput;
import javax.wsdl.Definition;
import javax.wsdl.Fault;
import javax.wsdl.Input;
import javax.wsdl.Operation;
import javax.wsdl.OperationType;
import javax.wsdl.Output;
import javax.wsdl.Port;
import javax.wsdl.PortType;
import javax.wsdl.Service;
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.wsdl.extensions.soap.SOAPBinding;
import javax.wsdl.extensions.soap.SOAPBody;
import javax.wsdl.extensions.soap.SOAPFault;
import javax.wsdl.extensions.soap.SOAPOperation;
import javax.wsdl.factory.WSDLFactory;
import javax.xml.namespace.QName;
import junit.framework.TestCase;
public class Soap11ProviderTest extends TestCase {
private Soap11Provider provider;
private Definition definition;
protected void setUp() throws Exception {
provider = new Soap11Provider();
WSDLFactory factory = WSDLFactory.newInstance();
definition = factory.newDefinition();
}
public void testPopulateBinding() throws Exception {
String namespace = "http://springframework.org/spring-ws";
definition.addNamespace("tns", namespace);
definition.setTargetNamespace(namespace);
PortType portType = definition.createPortType();
portType.setQName(new QName(namespace, "PortType"));
portType.setUndefined(false);
definition.addPortType(portType);
Operation operation = definition.createOperation();
operation.setName("Operation");
operation.setUndefined(false);
operation.setStyle(OperationType.REQUEST_RESPONSE);
portType.addOperation(operation);
Input input = definition.createInput();
input.setName("Input");
operation.setInput(input);
Output output = definition.createOutput();
output.setName("Output");
operation.setOutput(output);
Fault fault = definition.createFault();
fault.setName("Fault");
operation.addFault(fault);
Properties soapActions = new Properties();
soapActions.setProperty("Operation", namespace + "/Action");
provider.setSoapActions(soapActions);
provider.setServiceName("Service");
String locationUri = "http://localhost:8080/services";
provider.setLocationUri(locationUri);
provider.addBindings(definition);
provider.addServices(definition);
Binding binding = definition.getBinding(new QName(namespace, "PortTypeSoap11"));
assertNotNull("No binding created", binding);
assertEquals("Invalid port type", portType, binding.getPortType());
assertEquals("Invalid amount of extensibility elements", 1, binding.getExtensibilityElements().size());
SOAPBinding soapBinding = (SOAPBinding) binding.getExtensibilityElements().get(0);
assertEquals("Invalid style", "document", soapBinding.getStyle());
assertEquals("Invalid amount of binding operations", 1, binding.getBindingOperations().size());
BindingOperation bindingOperation = binding.getBindingOperation("Operation", "Input", "Output");
assertNotNull("No binding operation created", bindingOperation);
assertEquals("Invalid amount of extensibility elements", 1, bindingOperation.getExtensibilityElements().size());
SOAPOperation soapOperation = (SOAPOperation) bindingOperation.getExtensibilityElements().get(0);
assertEquals("Invalid SOAPAction", namespace + "/Action", soapOperation.getSoapActionURI());
BindingInput bindingInput = bindingOperation.getBindingInput();
assertNotNull("No binding input", bindingInput);
assertEquals("Invalid name", "Input", bindingInput.getName());
assertEquals("Invalid amount of extensibility elements", 1, bindingInput.getExtensibilityElements().size());
SOAPBody soapBody = (SOAPBody) bindingInput.getExtensibilityElements().get(0);
assertEquals("Invalid soap body use", "literal", soapBody.getUse());
BindingOutput bindingOutput = bindingOperation.getBindingOutput();
assertNotNull("No binding output", bindingOutput);
assertEquals("Invalid name", "Output", bindingOutput.getName());
assertEquals("Invalid amount of extensibility elements", 1, bindingOutput.getExtensibilityElements().size());
soapBody = (SOAPBody) bindingOutput.getExtensibilityElements().get(0);
assertEquals("Invalid soap body use", "literal", soapBody.getUse());
BindingFault bindingFault = bindingOperation.getBindingFault("Fault");
assertNotNull("No binding fault", bindingFault);
assertEquals("Invalid amount of extensibility elements", 1, bindingFault.getExtensibilityElements().size());
SOAPFault soapFault = (SOAPFault) bindingFault.getExtensibilityElements().get(0);
assertEquals("Invalid soap fault use", "literal", soapFault.getUse());
Service service = definition.getService(new QName(namespace, "Service"));
assertNotNull("No Service created", service);
assertEquals("Invalid amount of ports", 1, service.getPorts().size());
Port port = service.getPort("PortTypeSoap11");
assertNotNull("No port created", port);
assertEquals("Invalid binding", binding, port.getBinding());
assertEquals("Invalid amount of extensibility elements", 1, port.getExtensibilityElements().size());
SOAPAddress soapAddress = (SOAPAddress) port.getExtensibilityElements().get(0);
assertEquals("Invalid soap address", locationUri, soapAddress.getLocationURI());
}
}

View File

@@ -1,142 +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.provider;
import java.util.Properties;
import javax.wsdl.Binding;
import javax.wsdl.BindingFault;
import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
import javax.wsdl.BindingOutput;
import javax.wsdl.Definition;
import javax.wsdl.Fault;
import javax.wsdl.Input;
import javax.wsdl.Operation;
import javax.wsdl.OperationType;
import javax.wsdl.Output;
import javax.wsdl.Port;
import javax.wsdl.PortType;
import javax.wsdl.Service;
import javax.wsdl.extensions.soap12.SOAP12Address;
import javax.wsdl.extensions.soap12.SOAP12Binding;
import javax.wsdl.extensions.soap12.SOAP12Body;
import javax.wsdl.extensions.soap12.SOAP12Fault;
import javax.wsdl.extensions.soap12.SOAP12Operation;
import javax.wsdl.factory.WSDLFactory;
import javax.xml.namespace.QName;
import junit.framework.TestCase;
public class Soap12ProviderTest extends TestCase {
private Soap12Provider provider;
private Definition definition;
protected void setUp() throws Exception {
provider = new Soap12Provider();
WSDLFactory factory = WSDLFactory.newInstance();
definition = factory.newDefinition();
}
public void testPopulateBinding() throws Exception {
String namespace = "http://springframework.org/spring-ws";
definition.addNamespace("tns", namespace);
definition.setTargetNamespace(namespace);
PortType portType = definition.createPortType();
portType.setQName(new QName(namespace, "PortType"));
portType.setUndefined(false);
definition.addPortType(portType);
Operation operation = definition.createOperation();
operation.setName("Operation");
operation.setUndefined(false);
operation.setStyle(OperationType.REQUEST_RESPONSE);
portType.addOperation(operation);
Input input = definition.createInput();
input.setName("Input");
operation.setInput(input);
Output output = definition.createOutput();
output.setName("Output");
operation.setOutput(output);
Fault fault = definition.createFault();
fault.setName("Fault");
operation.addFault(fault);
Properties soapActions = new Properties();
soapActions.setProperty("Operation", namespace + "/Action");
provider.setSoapActions(soapActions);
provider.setServiceName("Service");
String locationUri = "http://localhost:8080/services";
provider.setLocationUri(locationUri);
provider.addBindings(definition);
provider.addServices(definition);
Binding binding = definition.getBinding(new QName(namespace, "PortTypeSoap12"));
assertNotNull("No binding created", binding);
assertEquals("Invalid port type", portType, binding.getPortType());
assertEquals("Invalid amount of extensibility elements", 1, binding.getExtensibilityElements().size());
SOAP12Binding soapBinding = (SOAP12Binding) binding.getExtensibilityElements().get(0);
assertEquals("Invalid style", "document", soapBinding.getStyle());
assertEquals("Invalid amount of binding operations", 1, binding.getBindingOperations().size());
BindingOperation bindingOperation = binding.getBindingOperation("Operation", "Input", "Output");
assertNotNull("No binding operation created", bindingOperation);
assertEquals("Invalid amount of extensibility elements", 1, bindingOperation.getExtensibilityElements().size());
SOAP12Operation soapOperation = (SOAP12Operation) bindingOperation.getExtensibilityElements().get(0);
assertEquals("Invalid SOAPAction", namespace + "/Action", soapOperation.getSoapActionURI());
BindingInput bindingInput = bindingOperation.getBindingInput();
assertNotNull("No binding input", bindingInput);
assertEquals("Invalid name", "Input", bindingInput.getName());
assertEquals("Invalid amount of extensibility elements", 1, bindingInput.getExtensibilityElements().size());
SOAP12Body soapBody = (SOAP12Body) bindingInput.getExtensibilityElements().get(0);
assertEquals("Invalid soap body use", "literal", soapBody.getUse());
BindingOutput bindingOutput = bindingOperation.getBindingOutput();
assertNotNull("No binding output", bindingOutput);
assertEquals("Invalid name", "Output", bindingOutput.getName());
assertEquals("Invalid amount of extensibility elements", 1, bindingOutput.getExtensibilityElements().size());
soapBody = (SOAP12Body) bindingOutput.getExtensibilityElements().get(0);
assertEquals("Invalid soap body use", "literal", soapBody.getUse());
BindingFault bindingFault = bindingOperation.getBindingFault("Fault");
assertNotNull("No binding fault", bindingFault);
assertEquals("Invalid amount of extensibility elements", 1, bindingFault.getExtensibilityElements().size());
SOAP12Fault soapFault = (SOAP12Fault) bindingFault.getExtensibilityElements().get(0);
assertEquals("Invalid soap fault use", "literal", soapFault.getUse());
Service service = definition.getService(new QName(namespace, "Service"));
assertNotNull("No Service created", service);
assertEquals("Invalid amount of ports", 1, service.getPorts().size());
Port port = service.getPort("PortTypeSoap12");
assertNotNull("No port created", port);
assertEquals("Invalid binding", binding, port.getBinding());
assertEquals("Invalid amount of extensibility elements", 1, port.getExtensibilityElements().size());
SOAP12Address soapAddress = (SOAP12Address) port.getExtensibilityElements().get(0);
assertEquals("Invalid soap address", locationUri, soapAddress.getLocationURI());
}
}

View File

@@ -1,102 +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.provider;
import java.util.Properties;
import javax.wsdl.Binding;
import javax.wsdl.Definition;
import javax.wsdl.Fault;
import javax.wsdl.Input;
import javax.wsdl.Operation;
import javax.wsdl.OperationType;
import javax.wsdl.Output;
import javax.wsdl.Port;
import javax.wsdl.PortType;
import javax.wsdl.Service;
import javax.wsdl.factory.WSDLFactory;
import javax.xml.namespace.QName;
import junit.framework.TestCase;
public class SoapProviderTest extends TestCase {
private SoapProvider provider;
private Definition definition;
protected void setUp() throws Exception {
provider = new SoapProvider();
WSDLFactory factory = WSDLFactory.newInstance();
definition = factory.newDefinition();
}
public void testPopulateBinding() throws Exception {
String namespace = "http://springframework.org/spring-ws";
definition.addNamespace("tns", namespace);
definition.setTargetNamespace(namespace);
PortType portType = definition.createPortType();
portType.setQName(new QName(namespace, "PortType"));
portType.setUndefined(false);
definition.addPortType(portType);
Operation operation = definition.createOperation();
operation.setName("Operation");
operation.setUndefined(false);
operation.setStyle(OperationType.REQUEST_RESPONSE);
portType.addOperation(operation);
Input input = definition.createInput();
input.setName("Input");
operation.setInput(input);
Output output = definition.createOutput();
output.setName("Output");
operation.setOutput(output);
Fault fault = definition.createFault();
fault.setName("Fault");
operation.addFault(fault);
Properties soapActions = new Properties();
soapActions.setProperty("Operation", namespace + "/Action");
provider.setSoapActions(soapActions);
provider.setServiceName("Service");
String locationUri = "http://localhost:8080/services";
provider.setLocationUri(locationUri);
provider.setCreateSoap11Binding(true);
provider.setCreateSoap12Binding(true);
provider.addBindings(definition);
provider.addServices(definition);
Binding binding = definition.getBinding(new QName(namespace, "PortTypeSoap11"));
assertNotNull("No SOAP 1.1 binding created", binding);
binding = definition.getBinding(new QName(namespace, "PortTypeSoap12"));
assertNotNull("No SOAP 1.2 binding created", binding);
Service service = definition.getService(new QName(namespace, "Service"));
assertNotNull("No Service created", service);
assertEquals("Invalid amount of ports", 2, service.getPorts().size());
Port port = service.getPort("PortTypeSoap11");
assertNotNull("No SOAP 1.1 port created", port);
port = service.getPort("PortTypeSoap12");
assertNotNull("No SOAP 1.2 port created", port);
}
}

View File

@@ -1,69 +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.provider;
import javax.wsdl.Definition;
import javax.wsdl.Message;
import javax.wsdl.Operation;
import javax.wsdl.PortType;
import javax.wsdl.factory.WSDLFactory;
import javax.xml.namespace.QName;
import junit.framework.TestCase;
public class SuffixBasedPortTypesProviderTest extends TestCase {
private SuffixBasedPortTypesProvider provider;
private Definition definition;
protected void setUp() throws Exception {
provider = new SuffixBasedPortTypesProvider();
WSDLFactory factory = WSDLFactory.newInstance();
definition = factory.newDefinition();
}
public void testAddPortTypes() throws Exception {
String namespace = "http://springframework.org/spring-ws";
definition.addNamespace("tns", namespace);
definition.setTargetNamespace(namespace);
Message message = definition.createMessage();
message.setQName(new QName(namespace, "OperationRequest"));
definition.addMessage(message);
message = definition.createMessage();
message.setQName(new QName(namespace, "OperationResponse"));
definition.addMessage(message);
message = definition.createMessage();
message.setQName(new QName(namespace, "OperationFault"));
definition.addMessage(message);
provider.setPortTypeName("PortType");
provider.addPortTypes(definition);
PortType portType = definition.getPortType(new QName(namespace, "PortType"));
assertNotNull("No port type created", portType);
Operation operation = portType.getOperation("Operation", "OperationRequest", "OperationResponse");
assertNotNull("No operation created", operation);
assertNotNull("No input created", operation.getInput());
assertNotNull("No output created", operation.getOutput());
assertFalse("No fault created", operation.getFaults().isEmpty());
}
}

View File

@@ -1,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,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,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:simpleType name="C">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:schema>

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:2"
xmlns="urn:2" elementFormDefault="qualified">
<xsd:include schemaLocation="C.xsd"/>
<xsd:simpleType name="D">
<xsd:restriction base="C"/>
</xsd:simpleType>
</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/schema"
xmlns="http://www.springframework.org/spring-ws/schema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:simpleType name="customType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:element name="GetOrderRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetOrderResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetOrderFault">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

View File

@@ -1,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>