Search in sources :

Example 61 with JaxWsProxyFactoryBean

use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.

the class AegisClientServerTest method testJaxWsAegisClient.

@Test
public void testJaxWsAegisClient() throws Exception {
    AegisDatabinding aegisBinding = new AegisDatabinding();
    JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
    proxyFactory.setDataBinding(aegisBinding);
    proxyFactory.setServiceClass(AuthService.class);
    proxyFactory.setAddress("http://localhost:" + PORT + "/jaxwsAndAegis");
    AuthService service = (AuthService) proxyFactory.create();
    assertTrue(service.authenticate("Joe", "Joe", "123"));
    assertFalse(service.authenticate("Joe1", "Joe", "fang"));
    assertTrue(service.authenticate("Joe", null, "123"));
    List<String> list = service.getRoles("Joe");
    assertEquals(3, list.size());
    assertEquals("Joe", list.get(0));
    assertEquals("Joe-1", list.get(1));
    assertEquals("Joe-2", list.get(2));
    String[] roles = service.getRolesAsArray("Joe");
    assertEquals(2, roles.length);
    assertEquals("Joe", roles[0]);
    assertEquals("Joe-1", roles[1]);
    roles = service.getRolesAsArray("null");
    assertNull(roles);
    roles = service.getRolesAsArray("0");
    assertEquals(0, roles.length);
    assertEquals("get Joe", service.getAuthentication("Joe"));
    Authenticate au = new Authenticate();
    au.setSid("ffang");
    au.setUid("ffang");
    assertTrue(service.authenticate(au));
    au.setUid("ffang1");
    assertFalse(service.authenticate(au));
}
Also used : Authenticate(org.apache.cxf.authservice.Authenticate) AuthService(org.apache.cxf.authservice.AuthService) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) Test(org.junit.Test)

Example 62 with JaxWsProxyFactoryBean

use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.

the class AegisClientServerTest method testReturnQualifiedPair.

@Test
public void testReturnQualifiedPair() throws Exception {
    AegisDatabinding aegisBinding = new AegisDatabinding();
    JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
    proxyFactory.setDataBinding(aegisBinding);
    proxyFactory.setServiceClass(SportsService.class);
    proxyFactory.setAddress("http://localhost:" + PORT + "/jaxwsAndAegisSports");
    proxyFactory.getInInterceptors().add(new LoggingInInterceptor());
    proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    SportsService service = (SportsService) proxyFactory.create();
    Pair<Integer, String> ret = service.getReturnQualifiedPair(111, "ffang");
    assertEquals(Integer.valueOf(111), ret.getFirst());
    assertEquals("ffang", ret.getSecond());
}
Also used : LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) Test(org.junit.Test)

Example 63 with JaxWsProxyFactoryBean

use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.

the class MtomTest method setupForTest.

private void setupForTest(boolean enableClientMTOM) throws Exception {
    AegisDatabinding aegisBinding = new AegisDatabinding();
    aegisBinding.setMtomEnabled(enableClientMTOM);
    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    proxyFac.setDataBinding(aegisBinding);
    proxyFac.setAddress("http://localhost:" + PORT + "/mtom");
    JaxWsProxyFactoryBean jaxwsFac = new JaxWsProxyFactoryBean();
    jaxwsFac.setDataBinding(new AegisDatabinding());
    jaxwsFac.setAddress("http://localhost:" + PORT + "/jaxWsMtom");
    Map<String, Object> props = new HashMap<>();
    if (enableClientMTOM) {
        props.put("mtom-enabled", Boolean.TRUE);
    }
    proxyFac.setProperties(props);
    client = proxyFac.create(MtomTestService.class);
    jaxwsClient = jaxwsFac.create(MtomTestService.class);
    impl = (MtomTestImpl) applicationContext.getBean("mtomImpl");
}
Also used : HashMap(java.util.HashMap) MtomTestService(org.apache.cxf.systest.aegis.mtom.fortest.MtomTestService) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding)

Example 64 with JaxWsProxyFactoryBean

use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.

the class DOCBareClientServerTest method testBare.

@Test
public void testBare() throws Exception {
    ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
    factory.setServiceClass(Server.BareSoapService.class);
    factory.setAddress("http://localhost:" + Server.PORT + "/SOAPDocLitBareService/SoapPort1");
    factory.setBus(BusFactory.newInstance().createBus());
    Server.BareSoapService client = (Server.BareSoapService) factory.create();
    try {
        client.doSomething();
        fail("This should fail, ClientProxyFactoryBean doesn't support @SOAPBinding annotation");
    } catch (IllegalStateException t) {
    // expected
    }
    factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(Server.BareSoapService.class);
    factory.setAddress("http://localhost:" + Server.PORT + "/SOAPDocLitBareService/SoapPort1");
    factory.setBus(BusFactory.newInstance().createBus());
    client = (Server.BareSoapService) factory.create();
    client.doSomething();
}
Also used : ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Test(org.junit.Test)

Example 65 with JaxWsProxyFactoryBean

use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.

the class UDPTransportTest method testBroadcastUDP.

@Test
public void testBroadcastUDP() throws Exception {
    // Disable the test on Redhat Enterprise Linux which doesn't enable the UDP broadcast by default
    if ("Linux".equals(System.getProperties().getProperty("os.name")) && System.getProperties().getProperty("os.version").indexOf("el") > 0) {
        System.out.println("Skipping broadcast test for REL");
        return;
    }
    Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
    int count = 0;
    if (interfaces != null) {
        while (interfaces.hasMoreElements()) {
            NetworkInterface networkInterface = interfaces.nextElement();
            if (!networkInterface.isUp() || networkInterface.isLoopback()) {
                continue;
            }
            count++;
        }
    }
    if (count == 0) {
        // no non-loopbacks, cannot do broadcasts
        System.out.println("Skipping broadcast test");
        return;
    }
    JaxWsProxyFactoryBean fact = new JaxWsProxyFactoryBean();
    fact.setAddress("udp://:" + PORT + "/foo");
    Greeter g = fact.create(Greeter.class);
    assertEquals("Hello World", g.greetMe("World"));
    ((java.io.Closeable) g).close();
}
Also used : Greeter(org.apache.hello_world.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) NetworkInterface(java.net.NetworkInterface) Test(org.junit.Test)

Aggregations

JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)152 Test (org.junit.Test)71 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)21 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)19 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)14 Greeter (org.apache.hello_world_soap_http.Greeter)14 Client (org.apache.cxf.endpoint.Client)13 HashMap (java.util.HashMap)10 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)9 QName (javax.xml.namespace.QName)8 WrappedGreeter (org.apache.hello_world_soap_action.WrappedGreeter)8 BookStoreService (org.apache.cxf.systest.jaxws.tracing.BookStoreService)7 ArrayList (java.util.ArrayList)6 ClientFactoryBean (org.apache.cxf.frontend.ClientFactoryBean)6 Holder (javax.xml.ws.Holder)5 Server (org.apache.cxf.endpoint.Server)5 Greeter (org.apache.cxf.greeter_control.Greeter)5 Service (org.apache.cxf.service.Service)5 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)5 Metadata (org.apache.cxf.ws.mex.model._2004_09.Metadata)5