use of org.apache.cxf.binding.BindingFactoryManager in project cxf by apache.
the class SoapBindingFactoryTest method testNoBodyParts.
@Test
public void testNoBodyParts() throws Exception {
Definition d = createDefinition("/wsdl_soap/no_body_parts.wsdl");
Bus bus = getMockBus();
BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.NS_SOAP11, bus);
bus.getExtension(BindingFactoryManager.class);
expectLastCall().andReturn(bfm).anyTimes();
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
control.replay();
WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
ServiceInfo serviceInfo = builder.buildServices(d, new QName("urn:org:apache:cxf:no_body_parts/wsdl", "NoBodyParts")).get(0);
BindingInfo bi = serviceInfo.getBindings().iterator().next();
assertTrue(bi instanceof SoapBindingInfo);
SoapBindingInfo sbi = (SoapBindingInfo) bi;
assertEquals("document", sbi.getStyle());
assertTrue(WSDLConstants.NS_SOAP11_HTTP_TRANSPORT.equalsIgnoreCase(sbi.getTransportURI()));
assertTrue(sbi.getSoapVersion() instanceof Soap11);
BindingOperationInfo boi = sbi.getOperation(new QName("urn:org:apache:cxf:no_body_parts/wsdl", "operation1"));
assertNotNull(boi);
SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
assertNotNull(sboi);
assertNull(sboi.getStyle());
assertEquals("", sboi.getAction());
BindingMessageInfo input = boi.getInput();
SoapBodyInfo bodyInfo = input.getExtensor(SoapBodyInfo.class);
assertNull(bodyInfo.getUse());
List<MessagePartInfo> parts = bodyInfo.getParts();
assertNotNull(parts);
assertEquals(0, parts.size());
}
use of org.apache.cxf.binding.BindingFactoryManager in project cxf by apache.
the class SoapBindingFactoryTest method testSoap12Factory.
@Test
public void testSoap12Factory() throws Exception {
Definition d = createDefinition("/wsdl_soap/hello_world_soap12.wsdl");
Bus bus = getMockBus();
BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.NS_SOAP12, bus);
expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm);
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
control.replay();
WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
ServiceInfo serviceInfo = builder.buildServices(d, new QName("http://apache.org/hello_world_soap12_http", "SOAPService")).get(0);
BindingInfo bi = serviceInfo.getBindings().iterator().next();
assertTrue(bi instanceof SoapBindingInfo);
SoapBindingInfo sbi = (SoapBindingInfo) bi;
assertEquals("document", sbi.getStyle());
assertEquals(WSDLConstants.NS_SOAP_HTTP_TRANSPORT, sbi.getTransportURI());
assertTrue(sbi.getSoapVersion() instanceof Soap12);
BindingOperationInfo boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap12_http", "sayHi"));
SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
assertNotNull(sboi);
assertEquals("document", sboi.getStyle());
assertEquals("sayHiAction", sboi.getAction());
BindingMessageInfo input = boi.getInput();
SoapBodyInfo bodyInfo = input.getExtensor(SoapBodyInfo.class);
assertEquals("literal", bodyInfo.getUse());
List<MessagePartInfo> parts = bodyInfo.getParts();
assertNotNull(parts);
assertEquals(1, parts.size());
boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap12_http", "pingMe"));
sboi = boi.getExtensor(SoapOperationInfo.class);
assertNotNull(sboi);
assertEquals("document", sboi.getStyle());
assertEquals("", sboi.getAction());
Collection<BindingFaultInfo> faults = boi.getFaults();
assertEquals(1, faults.size());
BindingFaultInfo faultInfo = boi.getFault(new QName("http://apache.org/hello_world_soap12_http", "pingMeFault"));
assertNotNull(faultInfo);
}
use of org.apache.cxf.binding.BindingFactoryManager in project cxf by apache.
the class SoapBindingFactoryTest method getBindingFactoryManager.
private BindingFactoryManager getBindingFactoryManager(String ns, Bus bus) throws BusException {
SoapBindingFactory bindingFactory = new SoapBindingFactory();
BindingFactoryManager bfm = new BindingFactoryManagerImpl();
bfm.registerBindingFactory(ns, bindingFactory);
return bfm;
}
use of org.apache.cxf.binding.BindingFactoryManager in project cxf by apache.
the class TestBase method getMockedServiceModel.
protected ServiceInfo getMockedServiceModel(String wsdlUrl) throws Exception {
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
Definition def = wsdlReader.readWSDL(wsdlUrl);
IMocksControl control = EasyMock.createNiceControl();
Bus bus = control.createMock(Bus.class);
BindingFactoryManager bindingFactoryManager = control.createMock(BindingFactoryManager.class);
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
Service service = null;
for (Iterator<?> it = def.getServices().values().iterator(); it.hasNext(); ) {
Object obj = it.next();
if (obj instanceof Service) {
service = (Service) obj;
break;
}
}
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
control.replay();
ServiceInfo serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
serviceInfo.setProperty(WSDLServiceBuilder.WSDL_DEFINITION, null);
serviceInfo.setProperty(WSDLServiceBuilder.WSDL_SERVICE, null);
return serviceInfo;
}
use of org.apache.cxf.binding.BindingFactoryManager in project cxf by apache.
the class AbstractJAXRSFactoryBean method createBindingInfo.
protected BindingInfo createBindingInfo() {
BindingFactoryManager mgr = getBus().getExtension(BindingFactoryManager.class);
String binding = getBindingId();
BindingConfiguration bindingConfig = getBindingConfig();
if (binding == null && bindingConfig != null) {
binding = bindingConfig.getBindingId();
}
if (binding == null) {
binding = JAXRSBindingFactory.JAXRS_BINDING_ID;
}
try {
BindingFactory bindingFactory = mgr.getBindingFactory(binding);
setBindingFactory(bindingFactory);
BindingInfo bi = bindingFactory.createBindingInfo(serviceFactory.getService(), binding, bindingConfig);
for (BindingOperationInfo boi : bi.getOperations()) {
serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_OPERATION_CREATED, bi, boi, null);
}
serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_CREATED, bi);
return bi;
} catch (BusException ex) {
ex.printStackTrace();
// do nothing
}
return null;
}
Aggregations