Java Code Examples for org.apache.cxf.frontend.ServerFactoryBean#setInvoker()

The following examples show how to use org.apache.cxf.frontend.ServerFactoryBean#setInvoker() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EJBEndpoint.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Server publish() throws Exception {
    jndiContext = new InitialContext();
    Object obj = jndiContext.lookup(config.getJNDIName());
    ejbHome = (EJBHome) PortableRemoteObject.narrow(obj, EJBHome.class);

    Class<?> interfaceClass = Class.forName(getServiceClassName());
    boolean isJaxws = isJaxWsServiceInterface(interfaceClass);
    ServerFactoryBean factory = isJaxws ? new JaxWsServerFactoryBean() : new ServerFactoryBean();
    factory.setServiceClass(interfaceClass);

    if (config.getWsdlURL() != null) {
        factory.getServiceFactory().setWsdlURL(config.getWsdlURL());
    }

    factory.setInvoker(new EJBInvoker(ejbHome));

    String baseAddress = isNotNull(getEjbServantBaseURL()) ? getEjbServantBaseURL()
                                                           : getDefaultEJBServantBaseURL();
    String address = baseAddress + "/" + config.getJNDIName();
    factory.setAddress(address);

    if (address.length() >= 5 && HTTPS_PREFIX.equalsIgnoreCase(address.substring(0, 5))) {
        throw new UnsupportedOperationException("EJBEndpoint creation by https protocol is unsupported");
    }

    if (getWorkManager() != null) {
        setWorkManagerThreadPoolToJetty(factory.getBus(), baseAddress);
    }

    Server server = factory.create();
    LOG.info("Published EJB Endpoint of [" + config.getJNDIName() + "] at [" + address + "]");

    return server;
}
 
Example 2
Source File: GreeterTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testEndpoint() throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(resource);
    bean.setWsdlURL(resource.toString());
    bean.setBus(bus);
    bean.setServiceClass(GreeterImpl.class);
    GreeterImpl greeter = new GreeterImpl();
    BeanInvoker invoker = new BeanInvoker(greeter);


    Service service = bean.create();

    assertEquals("SOAPService", service.getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_soap_http", service.getName().getNamespaceURI());

    ServerFactoryBean svr = new ServerFactoryBean();
    svr.setBus(bus);
    svr.setServiceFactory(bean);
    svr.setInvoker(invoker);

    svr.create();

    Node response = invoke("http://localhost:9000/SoapContext/SoapPort",
                       LocalTransportFactory.TRANSPORT_ID,
                       "GreeterMessage.xml");

    assertEquals(1, greeter.getInvocationCount());

    assertNotNull(response);

    addNamespace("h", "http://apache.org/hello_world_soap_http/types");

    assertValid("/s:Envelope/s:Body", response);
    assertValid("//h:sayHiResponse", response);
}