Search in sources :

Example 36 with ClientProxyFactoryBean

use of org.apache.cxf.frontend.ClientProxyFactoryBean in project cxf by apache.

the class ClientServiceConfigTest method ordinaryParamNameTest.

@Test
public void ordinaryParamNameTest() throws Exception {
    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    ReflectionServiceFactoryBean factory = new ReflectionServiceFactoryBean();
    proxyFac.setServiceFactory(factory);
    proxyFac.setDataBinding(new AegisDatabinding());
    proxyFac.setAddress("local://Echo");
    proxyFac.setBus(getBus());
    Echo echo = proxyFac.create(Echo.class);
    String boing = echo.simpleEcho("reflection");
    assertEquals("reflection", boing);
}
Also used : ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 37 with ClientProxyFactoryBean

use of org.apache.cxf.frontend.ClientProxyFactoryBean in project cxf by apache.

the class SpringBeansTest method testClients.

@Test
public void testClients() throws Exception {
    AbstractFactoryBeanDefinitionParser.setFactoriesAreAbstract(false);
    ctx = new ClassPathXmlApplicationContext(new String[] { "/org/apache/cxf/frontend/spring/clients.xml" });
    Object bean = ctx.getBean("client1.proxyFactory");
    assertNotNull(bean);
    ClientProxyFactoryBean cpfbean = (ClientProxyFactoryBean) bean;
    BindingConfiguration bc = cpfbean.getBindingConfig();
    assertTrue(bc instanceof SoapBindingConfiguration);
    SoapBindingConfiguration sbc = (SoapBindingConfiguration) bc;
    assertTrue(sbc.getVersion() instanceof Soap12);
    HelloService greeter = (HelloService) ctx.getBean("client1");
    assertNotNull(greeter);
    Client client = ClientProxy.getClient(greeter);
    assertNotNull("expected ConduitSelector", client.getConduitSelector());
    assertTrue("unexpected ConduitSelector", client.getConduitSelector() instanceof NullConduitSelector);
    List<Interceptor<? extends Message>> inInterceptors = client.getInInterceptors();
    boolean saaj = false;
    boolean logging = false;
    for (Interceptor<? extends Message> i : inInterceptors) {
        if (i instanceof SAAJInInterceptor) {
            saaj = true;
        } else if (i instanceof LoggingInInterceptor) {
            logging = true;
        }
    }
    assertTrue(saaj);
    assertTrue(logging);
    saaj = false;
    logging = false;
    for (Interceptor<?> i : client.getOutInterceptors()) {
        if (i instanceof SAAJOutInterceptor) {
            saaj = true;
        } else if (i instanceof LoggingOutInterceptor) {
            logging = true;
        }
    }
    assertTrue(saaj);
    assertTrue(logging);
    ClientProxyFactoryBean clientProxyFactoryBean = (ClientProxyFactoryBean) ctx.getBean("client2.proxyFactory");
    assertNotNull(clientProxyFactoryBean);
    assertEquals("get the wrong transportId", clientProxyFactoryBean.getTransportId(), "http://cxf.apache.org/transports/local");
    assertEquals("get the wrong bindingId", clientProxyFactoryBean.getBindingId(), "http://cxf.apache.org/bindings/xformat");
    greeter = (HelloService) ctx.getBean("client2");
    assertNotNull(greeter);
    greeter = (HelloService) ctx.getBean("client3");
    assertNotNull(greeter);
    client = ClientProxy.getClient(greeter);
    EndpointInfo epi = client.getEndpoint().getEndpointInfo();
    AuthorizationPolicy ap = epi.getExtensor(AuthorizationPolicy.class);
    assertNotNull("The AuthorizationPolicy instance should not be null", ap);
    assertEquals("Get the wrong username", ap.getUserName(), "testUser");
    assertEquals("Get the wrong password", ap.getPassword(), "password");
}
Also used : Soap12(org.apache.cxf.binding.soap.Soap12) SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) Message(org.apache.cxf.message.Message) HelloService(org.apache.cxf.service.factory.HelloService) NullConduitSelector(org.apache.cxf.endpoint.NullConduitSelector) SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) BindingConfiguration(org.apache.cxf.binding.BindingConfiguration) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) Test(org.junit.Test)

Example 38 with ClientProxyFactoryBean

use of org.apache.cxf.frontend.ClientProxyFactoryBean in project cxf by apache.

the class FlatArrayTest method testDataMovementBean.

@Test
public void testDataMovementBean() throws Exception {
    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    proxyFac.setDataBinding(new AegisDatabinding());
    proxyFac.setAddress("local://FlatArray");
    proxyFac.setBus(getBus());
    FlatArrayServiceInterface client = proxyFac.create(FlatArrayServiceInterface.class);
    BeanWithFlatArray bwfa = new BeanWithFlatArray();
    bwfa.setValues(INT_ARRAY);
    client.takeBeanWithFlatArray(bwfa);
    assertArrayEquals(INT_ARRAY, service.beanWithFlatArrayValue.getValues());
}
Also used : ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 39 with ClientProxyFactoryBean

use of org.apache.cxf.frontend.ClientProxyFactoryBean in project cxf by apache.

the class FlatArrayTest method testDataMovementPart.

@Test
public void testDataMovementPart() throws Exception {
    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    proxyFac.setDataBinding(new AegisDatabinding());
    proxyFac.setAddress("local://FlatArray");
    proxyFac.setBus(getBus());
    FlatArrayServiceInterface client = proxyFac.create(FlatArrayServiceInterface.class);
    client.submitStringArray(STRING_ARRAY);
    assertArrayEquals(STRING_ARRAY, service.stringArrayValue);
}
Also used : ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 40 with ClientProxyFactoryBean

use of org.apache.cxf.frontend.ClientProxyFactoryBean in project cxf by apache.

the class MissingTypeWSDLTest method testMissingTransliteration.

@Test
public void testMissingTransliteration() throws Exception {
    Server server = createService(MissingType.class, new MissingTypeImpl(), null);
    Service service = server.getEndpoint().getService();
    service.setInvoker(new BeanInvoker(new MissingTypeImpl()));
    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    proxyFac.setAddress("local://MissingType");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());
    Document wsdl = getWSDLDocument("MissingType");
    assertValid("/wsdl:definitions/wsdl:types" + "/xsd:schema[@targetNamespace='urn:org:apache:cxf:aegis:type:missing']" + "/xsd:complexType[@name=\"Inner\"]", wsdl);
}
Also used : Server(org.apache.cxf.endpoint.Server) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) Service(org.apache.cxf.service.Service) Document(org.w3c.dom.Document) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Aggregations

ClientProxyFactoryBean (org.apache.cxf.frontend.ClientProxyFactoryBean)43 Test (org.junit.Test)23 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)12 ClientFactoryBean (org.apache.cxf.frontend.ClientFactoryBean)12 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)10 Client (org.apache.cxf.endpoint.Client)4 Server (org.apache.cxf.endpoint.Server)4 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)4 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)3 BeanInvoker (org.apache.cxf.service.invoker.BeanInvoker)3 Before (org.junit.Before)3 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)3 Document (org.w3c.dom.Document)3 CustomerService (com.example.customerservice.CustomerService)2 HashMap (java.util.HashMap)2 QName (javax.xml.namespace.QName)2 AegisContext (org.apache.cxf.aegis.AegisContext)2 JaxbElementTest (org.apache.cxf.jaxb_element_test.JaxbElementTest)2 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)2 Service (org.apache.cxf.service.Service)2