Search in sources :

Example 21 with DestinationFactoryManager

use of org.apache.cxf.transport.DestinationFactoryManager in project cxf by apache.

the class TestBase method common.

protected void common(String wsdl, QName portName, Class<?>... jaxbClasses) throws Exception {
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    WSDLManagerImpl manager = new WSDLManagerImpl();
    XMLWSDLExtensionLoader.registerExtensors(manager);
    EasyMock.expect(bus.getExtension(WSDLManager.class)).andStubReturn(manager);
    BindingFactoryManager bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andStubReturn(bindingFactoryManager);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
    control.replay();
    assertNotNull(bus.getExtension(WSDLManager.class));
    WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass().getResource(wsdl).toString(), new QName(portName.getNamespaceURI(), "XMLService"));
    org.apache.cxf.service.Service service = factory.create();
    EndpointInfo epi = service.getEndpointInfo(portName);
    serviceInfo = epi.getService();
    assertNotNull(epi);
    Binding xmlBinding = new XMLBindingFactory().createBinding(epi.getBinding());
    control.reset();
    JAXBDataBinding db = new JAXBDataBinding();
    db.initialize(service);
    db.setContext(JAXBContext.newInstance(jaxbClasses));
    service.setDataBinding(db);
    Endpoint endpoint = control.createMock(EndpointImpl.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andStubReturn(epi);
    EasyMock.expect(endpoint.getBinding()).andStubReturn(xmlBinding);
    EasyMock.expect(endpoint.getService()).andStubReturn(service);
    EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();
    control.replay();
    xmlMessage.getExchange().put(Endpoint.class, endpoint);
    xmlMessage.getExchange().put(org.apache.cxf.service.Service.class, service);
}
Also used : Binding(org.apache.cxf.binding.Binding) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) Bus(org.apache.cxf.Bus) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) QName(javax.xml.namespace.QName) WSDLManagerImpl(org.apache.cxf.wsdl11.WSDLManagerImpl) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) WSDLManager(org.apache.cxf.wsdl.WSDLManager) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) XMLBindingFactory(org.apache.cxf.binding.xml.XMLBindingFactory)

Example 22 with DestinationFactoryManager

use of org.apache.cxf.transport.DestinationFactoryManager 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);
}
Also used : Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) SoapBodyInfo(org.apache.cxf.binding.soap.model.SoapBodyInfo) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) Test(org.junit.Test)

Example 23 with DestinationFactoryManager

use of org.apache.cxf.transport.DestinationFactoryManager 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());
}
Also used : Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) SoapBodyInfo(org.apache.cxf.binding.soap.model.SoapBodyInfo) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) Test(org.junit.Test)

Example 24 with DestinationFactoryManager

use of org.apache.cxf.transport.DestinationFactoryManager 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;
}
Also used : IMocksControl(org.easymock.IMocksControl) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) Definition(javax.wsdl.Definition) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) Service(javax.wsdl.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 25 with DestinationFactoryManager

use of org.apache.cxf.transport.DestinationFactoryManager in project cxf by apache.

the class JAXBDataBindingTest method setUp.

@Before
public void setUp() throws Exception {
    jaxbDataBinding = new JAXBDataBinding();
    String wsdlUrl = getClass().getResource(WSDL_PATH).toString();
    LOG.info("the path of wsdl file is " + wsdlUrl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    def = wsdlReader.readWSDL(wsdlUrl);
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andStubReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(destinationFactoryManager);
    control.replay();
    WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
    for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
        if (serv != null) {
            service = serv;
            break;
        }
    }
    wsdlServiceBuilder.buildServices(def, service);
}
Also used : Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) Service(javax.wsdl.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) WSDLReader(javax.wsdl.xml.WSDLReader) Before(org.junit.Before)

Aggregations

DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)40 Bus (org.apache.cxf.Bus)23 DestinationFactory (org.apache.cxf.transport.DestinationFactory)18 ConduitInitiatorManager (org.apache.cxf.transport.ConduitInitiatorManager)16 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)15 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)13 QName (javax.xml.namespace.QName)9 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)8 WSDLServiceBuilder (org.apache.cxf.wsdl11.WSDLServiceBuilder)8 Before (org.junit.Before)8 Test (org.junit.Test)8 Destination (org.apache.cxf.transport.Destination)7 BindingInfo (org.apache.cxf.service.model.BindingInfo)6 Definition (javax.wsdl.Definition)5 Service (javax.wsdl.Service)5 WSDLReader (javax.wsdl.xml.WSDLReader)5 SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)5 LocalTransportFactory (org.apache.cxf.transport.local.LocalTransportFactory)5 BusException (org.apache.cxf.BusException)4 ConduitInitiator (org.apache.cxf.transport.ConduitInitiator)4