Soap12Provider extends DefaultConcretePartProvider { @Override protected void populateBinding(Definition definition, Binding binding) throws WSDLException { definition.addNamespace(SOAP_12_NAMESPACE_PREFIX, SOAP_12_NAMESPACE_URI); super.populateBinding(definition, binding); SOAP12Binding soapBinding = (SOAP12Binding) createSoapExtension(definition, Binding.class, "binding"); populateSoapBinding(soapBinding, binding); binding.addExtensibilityElement(soapBinding); } Soap12Provider(); Properties getSoapActions(); void setSoapActions(Properties soapActions); String getTransportUri(); void setTransportUri(String transportUri); String getLocationUri(); void setLocationUri(String locationUri); static final String DEFAULT_TRANSPORT_URI; static final String SOAP_12_NAMESPACE_PREFIX; static final String SOAP_12_NAMESPACE_URI; }
@Test public void testPopulateBinding() throws Exception { String namespace = "http: 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: provider.setLocationUri(locationUri); provider.addBindings(definition); provider.addServices(definition); Binding binding = definition.getBinding(new QName(namespace, "PortTypeSoap12")); Assert.assertNotNull("No binding created", binding); Assert.assertEquals("Invalid port type", portType, binding.getPortType()); Assert.assertEquals("Invalid amount of extensibility elements", 1, binding.getExtensibilityElements().size()); SOAP12Binding soapBinding = (SOAP12Binding) binding.getExtensibilityElements().get(0); Assert.assertEquals("Invalid style", "document", soapBinding.getStyle()); Assert.assertEquals("Invalid amount of binding operations", 1, binding.getBindingOperations().size()); BindingOperation bindingOperation = binding.getBindingOperation("Operation", "Input", "Output"); Assert.assertNotNull("No binding operation created", bindingOperation); Assert.assertEquals("Invalid amount of extensibility elements", 1, bindingOperation.getExtensibilityElements().size()); SOAP12Operation soapOperation = (SOAP12Operation) bindingOperation.getExtensibilityElements().get(0); Assert.assertEquals("Invalid SOAPAction", namespace + "/Action", soapOperation.getSoapActionURI()); BindingInput bindingInput = bindingOperation.getBindingInput(); Assert.assertNotNull("No binding input", bindingInput); Assert.assertEquals("Invalid name", "Input", bindingInput.getName()); Assert.assertEquals("Invalid amount of extensibility elements", 1, bindingInput.getExtensibilityElements().size()); SOAP12Body soapBody = (SOAP12Body) bindingInput.getExtensibilityElements().get(0); Assert.assertEquals("Invalid soap body use", "literal", soapBody.getUse()); BindingOutput bindingOutput = bindingOperation.getBindingOutput(); Assert.assertNotNull("No binding output", bindingOutput); Assert.assertEquals("Invalid name", "Output", bindingOutput.getName()); Assert.assertEquals("Invalid amount of extensibility elements", 1, bindingOutput.getExtensibilityElements().size()); soapBody = (SOAP12Body) bindingOutput.getExtensibilityElements().get(0); Assert.assertEquals("Invalid soap body use", "literal", soapBody.getUse()); BindingFault bindingFault = bindingOperation.getBindingFault("Fault"); Assert.assertNotNull("No binding fault", bindingFault); Assert.assertEquals("Invalid amount of extensibility elements", 1, bindingFault.getExtensibilityElements().size()); SOAP12Fault soapFault = (SOAP12Fault) bindingFault.getExtensibilityElements().get(0); Assert.assertEquals("Invalid soap fault use", "literal", soapFault.getUse()); Service service = definition.getService(new QName(namespace, "Service")); Assert.assertNotNull("No Service created", service); Assert.assertEquals("Invalid amount of ports", 1, service.getPorts().size()); Port port = service.getPort("PortTypeSoap12"); Assert.assertNotNull("No port created", port); Assert.assertEquals("Invalid binding", binding, port.getBinding()); Assert.assertEquals("Invalid amount of extensibility elements", 1, port.getExtensibilityElements().size()); SOAP12Address soapAddress = (SOAP12Address) port.getExtensibilityElements().get(0); Assert.assertEquals("Invalid soap address", locationUri, soapAddress.getLocationURI()); }