use of javax.wsdl.extensions.soap12.SOAP12Binding in project jbossws-cxf by jbossws.
the class SOAPBindingTestCase method testWSDLAccess.
// [JBWS-1761] - WSProvide ignores SOAPBinding declaration
@Test
@RunAsClient
public void testWSDLAccess() throws Exception {
URL wsdlURL = new URL(baseURL + "?wsdl");
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
Definition wsdl = wsdlReader.readWSDL(wsdlURL.toString());
String port = "SOAPEndpointPort";
QName serviceQName = new QName("http://org.jboss.ws/jaxws/binding", "SOAPEndpointService");
Binding wsdlBinding = wsdl.getService(serviceQName).getPort(port).getBinding();
assertNotNull("Cannot find binding for port: " + port, wsdlBinding);
String transport = null;
@SuppressWarnings("unchecked") List<ExtensibilityElement> extList = wsdlBinding.getExtensibilityElements();
for (ExtensibilityElement ext : extList) {
if (ext instanceof SOAPBinding) {
fail("Expected SOAP-1.2 binding");
} else if (ext instanceof SOAP12Binding) {
SOAP12Binding soapBinding = (SOAP12Binding) ext;
transport = soapBinding.getTransportURI();
}
}
if (isIntegrationCXF()) {
System.out.println("FIXME: [CXF-2531] Wrong \"transport\" attribute in soap12:binding");
} else {
assertEquals("Invalid transport uri", "http://schemas.xmlsoap.org/soap/http", transport);
}
}
use of javax.wsdl.extensions.soap12.SOAP12Binding in project jbossws-cxf by jbossws.
the class JBWS2183TestCase method testWsdl.
@Test
@RunAsClient
public void testWsdl() throws Exception {
URL wsdlURL = new URL(baseURL + "/jaxws-jbws2183/TestServiceImpl?wsdl");
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
Definition wsdlDefinition = wsdlReader.readWSDL(wsdlURL.toString());
assertNotNull(wsdlDefinition);
for (Iterator<?> it = wsdlDefinition.getAllBindings().values().iterator(); it.hasNext(); ) {
List<?> extElements = ((Binding) it.next()).getExtensibilityElements();
boolean found = false;
for (int i = 0; i < extElements.size(); i++) {
ExtensibilityElement extElement = (ExtensibilityElement) extElements.get(i);
if (extElement instanceof SOAP12Binding)
found = true;
else if (extElement instanceof SOAPBinding)
fail("SOAP 1.1 Binding found!");
}
assertTrue("SOAP 1.2 Binding not found!", found);
}
}
use of javax.wsdl.extensions.soap12.SOAP12Binding in project cxf by apache.
the class ServiceImpl method initializePorts.
private void initializePorts() {
try {
Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL);
javax.wsdl.Service serv = def.getService(serviceName);
if (serv == null) {
throw new WebServiceException("Could not find service named " + serviceName + " in wsdl " + wsdlURL);
}
Map<String, Port> wsdlports = CastUtils.cast(serv.getPorts());
for (Port port : wsdlports.values()) {
QName name = new QName(serviceName.getNamespaceURI(), port.getName());
String address = null;
String bindingID = null;
List<? extends ExtensibilityElement> extensions = CastUtils.cast(port.getBinding().getExtensibilityElements());
if (!extensions.isEmpty()) {
ExtensibilityElement e = extensions.get(0);
if (e instanceof SoapBinding) {
bindingID = SOAPBinding.SOAP11HTTP_BINDING;
} else if (e instanceof SOAP12Binding) {
bindingID = SOAPBinding.SOAP12HTTP_BINDING;
} else if (e instanceof javax.wsdl.extensions.soap.SOAPBinding) {
bindingID = SOAPBinding.SOAP11HTTP_BINDING;
}
}
extensions = CastUtils.cast(port.getExtensibilityElements());
if (!extensions.isEmpty()) {
ExtensibilityElement e = extensions.get(0);
if (e instanceof SoapAddress) {
address = ((SoapAddress) e).getLocationURI();
} else if (e instanceof AddressType) {
address = ((AddressType) e).getLocation();
} else if (e instanceof SOAP12Address) {
address = ((SOAP12Address) e).getLocationURI();
} else if (e instanceof SOAPAddress) {
address = ((SOAPAddress) e).getLocationURI();
} else if (e instanceof HTTPAddress) {
address = ((HTTPAddress) e).getLocationURI();
}
}
addPort(name, bindingID, address);
}
} catch (WebServiceException e) {
throw e;
} catch (Throwable e) {
if (e instanceof UncheckedException && LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, e.getLocalizedMessage(), e);
}
WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
Service service = sf.create();
for (ServiceInfo si : service.getServiceInfos()) {
for (EndpointInfo ei : si.getEndpoints()) {
String bindingID = BindingID.getJaxwsBindingID(ei.getTransportId());
addPort(ei.getName(), bindingID, ei.getAddress());
}
}
}
}
use of javax.wsdl.extensions.soap12.SOAP12Binding in project cxf by apache.
the class WSDLToSoapProcessorTest method testNewSoap12Binding.
@Test
public void testNewSoap12Binding() throws Exception {
String[] args = new String[] { "-i", "Greeter", "-soap12", "-b", "Greeter_SOAP12Binding", "-d", output.getCanonicalPath(), "-o", "hello_world_soap12_newbinding.wsdl", getLocation("/misctools_wsdl/hello_world_soap12_nobinding.wsdl") };
WSDLToSoap.main(args);
File outputFile = new File(output, "hello_world_soap12_newbinding.wsdl");
assertTrue("New wsdl file is not generated", outputFile.exists());
assertTrue("Generated file is empty!", outputFile.length() > 0);
WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
processor.setEnvironment(env);
try {
processor.parseWSDL(outputFile.getAbsolutePath());
Binding binding = processor.getWSDLDefinition().getBinding(new QName(processor.getWSDLDefinition().getTargetNamespace(), "Greeter_SOAP12Binding"));
if (binding == null) {
fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!");
}
for (Object obj : binding.getExtensibilityElements()) {
assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
assertTrue(obj instanceof SOAP12Binding);
SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
assertNotNull(soapBinding);
assertTrue("document".equalsIgnoreCase(soapBinding.getStyle()));
assertTrue(WSDLConstants.NS_SOAP_HTTP_TRANSPORT.equalsIgnoreCase(soapBinding.getTransportURI()));
}
BindingOperation bo = binding.getBindingOperation("sayHi", null, null);
if (bo == null) {
fail("Element <wsdl:operation name=\"sayHi\"> Missed!");
}
for (Object obj : bo.getExtensibilityElements()) {
assertTrue(SOAPBindingUtil.isSOAPOperation(obj));
assertTrue(obj instanceof SOAP12Operation);
SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
assertNotNull(soapOperation);
assertTrue("document".equalsIgnoreCase(soapOperation.getStyle()));
}
BindingInput bi = bo.getBindingInput();
for (Object obj : bi.getExtensibilityElements()) {
assertTrue(SOAPBindingUtil.isSOAPBody(obj));
assertTrue(obj instanceof SOAP12Body);
SoapBody soapBody = SOAPBindingUtil.getSoapBody(obj);
assertNotNull(soapBody);
assertTrue("literal".equalsIgnoreCase(soapBody.getUse()));
}
} catch (ToolException e) {
fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
}
}
use of javax.wsdl.extensions.soap12.SOAP12Binding in project cxf by apache.
the class WSDLToSoapProcessorTest method testAddSoap12Binding.
@Test
public void testAddSoap12Binding() throws Exception {
String[] args = new String[] { "-i", "Greeter", "-soap12", "-b", "Greeter_SOAP12Binding", "-d", output.getCanonicalPath(), "-o", "hello_world_soap12_newbinding.wsdl", getLocation("/misctools_wsdl/hello_world_soap12.wsdl") };
WSDLToSoap.main(args);
File outputFile = new File(output, "hello_world_soap12_newbinding.wsdl");
assertTrue("New wsdl file is not generated", outputFile.exists());
WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
processor.setEnvironment(env);
try {
processor.parseWSDL(outputFile.getAbsolutePath());
Binding binding = processor.getWSDLDefinition().getBinding(new QName(processor.getWSDLDefinition().getTargetNamespace(), "Greeter_SOAP12Binding"));
if (binding == null) {
fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!");
}
for (Object obj : binding.getExtensibilityElements()) {
assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
assertTrue(obj instanceof SOAP12Binding);
SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
assertNotNull(soapBinding);
assertTrue("document".equalsIgnoreCase(soapBinding.getStyle()));
}
BindingOperation bo = binding.getBindingOperation("sayHi", null, null);
if (bo == null) {
fail("Element <wsdl:operation name=\"sayHi\"> Missed!");
}
for (Object obj : bo.getExtensibilityElements()) {
assertTrue(SOAPBindingUtil.isSOAPOperation(obj));
assertTrue(obj instanceof SOAP12Operation);
SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
assertNotNull(soapOperation);
assertTrue("document".equalsIgnoreCase(soapOperation.getStyle()));
}
BindingInput bi = bo.getBindingInput();
for (Object obj : bi.getExtensibilityElements()) {
assertTrue(SOAPBindingUtil.isSOAPBody(obj));
assertTrue(obj instanceof SOAP12Body);
SoapBody soapBody = SOAPBindingUtil.getSoapBody(obj);
assertNotNull(soapBody);
assertTrue("literal".equalsIgnoreCase(soapBody.getUse()));
}
bo = binding.getBindingOperation("pingMe", null, null);
assertNotNull(bo);
Iterator<?> it = bo.getExtensibilityElements().iterator();
assertTrue(it != null && it.hasNext());
assertTrue(it.next() instanceof SOAP12Operation);
it = bo.getBindingInput().getExtensibilityElements().iterator();
assertTrue(it != null && it.hasNext());
assertTrue(it.next() instanceof SOAP12Body);
it = bo.getBindingOutput().getExtensibilityElements().iterator();
assertTrue(it != null && it.hasNext());
assertTrue(it.next() instanceof SOAP12Body);
Map<?, ?> faults = bo.getBindingFaults();
assertTrue(faults != null && faults.size() == 1);
Object bf = faults.get("pingMeFault");
assertNotNull(bf);
assertTrue(bf instanceof BindingFault);
assertEquals("pingMeFault", ((BindingFault) bf).getName());
} catch (ToolException e) {
fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
}
}
Aggregations