Java Code Examples for org.apache.cxf.jaxws.JaxWsProxyFactoryBean#setDataBinding()

The following examples show how to use org.apache.cxf.jaxws.JaxWsProxyFactoryBean#setDataBinding() . 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: AegisClientServerTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testCollection() throws Exception {
    AegisDatabinding aegisBinding = new AegisDatabinding();
    JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
    proxyFactory.setDataBinding(aegisBinding);
    proxyFactory.setServiceClass(SportsService.class);
    proxyFactory.setWsdlLocation("http://localhost:" + PORT + "/jaxwsAndAegisSports?wsdl");
    proxyFactory.getInInterceptors().add(new LoggingInInterceptor());
    proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    SportsService service = (SportsService) proxyFactory.create();

    Collection<Team> teams = service.getTeams();
    assertEquals(1, teams.size());
    assertEquals("Patriots", teams.iterator().next().getName());

    //CXF-1251
    String s = service.testForMinOccurs0("A", null, "b");
    assertEquals("Anullb", s);
}
 
Example 2
Source File: AegisClientServerTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testComplexMapResult() 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();
    Map<String, Map<Integer, Integer>> result = service.testComplexMapResult();
    assertEquals(result.size(), 1);
    assertTrue(result.containsKey("key1"));
    assertNotNull(result.get("key1"));
    assertEquals(result.toString(), "{key1={1=3}}");
}
 
Example 3
Source File: MtomTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
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");
}
 
Example 4
Source File: CustomBeansTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testClientSetup() throws Exception {

    JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
    clientFactory.setAddress("local:not-really");
    clientFactory.setServiceClass(Service.class);

    AegisDatabinding dataBinding = new AegisDatabinding();

    NoDefaultConstructorBeanTypeRegistrar beanRegistrar
        = new NoDefaultConstructorBeanTypeRegistrar();
    beanRegistrar.setDataBinding(dataBinding);
    beanRegistrar.register();

    NoDefaultConstructorBeanKeyTypeRegistrar beanKeyRegistrar
        = new NoDefaultConstructorBeanKeyTypeRegistrar();
    beanKeyRegistrar.setDataBinding(dataBinding);
    beanKeyRegistrar.register();

    clientFactory.setDataBinding(dataBinding);

    clientFactory.create();
    String uri = dataBinding.getAegisContext().getTypeMapping().getMappingIdentifierURI();
    assertNotSame(DefaultTypeMapping.DEFAULT_MAPPING_URI, uri);
}
 
Example 5
Source File: AegisClientServerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example 6
Source File: AegisClientServerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testGenericCollection() 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();
    List<String> list = new ArrayList<>();
    list.add("ffang");
    String ret = service.getGeneric(list);
    assertEquals(ret, "ffang");
}
 
Example 7
Source File: AegisClientServerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testGenericPair() 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<String, Integer> ret = service.getReturnGenericPair("ffang", 111);
    assertEquals("ffang", ret.getFirst());
    assertEquals(Integer.valueOf(111), ret.getSecond());
}
 
Example 8
Source File: AegisClientServerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example 9
Source File: AegisClientServerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testReturnGenericPair() 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();
    int ret = service.getGenericPair(new Pair<Integer, String>(111, "String"));
    assertEquals(111, ret);
}
 
Example 10
Source File: AegisClientServerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testQualifiedPair() 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();
    int ret = service.getQualifiedPair(new Pair<Integer, String>(111, "ffang"));
    assertEquals(111, ret);
}
 
Example 11
Source File: ClientServiceConfigTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void talkToJaxWsHolder() throws Exception {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setDataBinding(new AegisDatabinding());
    factory.setAddress("local://JaxWsEcho");
    Echo client = factory.create(Echo.class);
    Holder<String> sholder = new Holder<>();
    client.echo("Channa Doll", sholder);
    assertEquals("Channa Doll", sholder.value);
}