Search in sources :

Example 31 with ClientProxyFactoryBean

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

the class CxfConsumerTest method testInvokingServiceFromCXFClient.

// END SNIPPET: example
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(SIMPLE_ENDPOINT_ADDRESS);
    clientBean.setServiceClass(HelloService.class);
    clientBean.setBus(BusFactory.newInstance().createBus());
    HelloService client = (HelloService) proxyFactory.create();
    String result = client.echo(TEST_MESSAGE);
    assertEquals("We should get the echo string result from router", result, "echo " + TEST_MESSAGE);
    Boolean bool = client.echoBoolean(Boolean.TRUE);
    assertNotNull("The result should not be null", bool);
    assertEquals("We should get the echo boolean result from router ", bool.toString(), "true");
}
Also used : ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) Test(org.junit.Test)

Example 32 with ClientProxyFactoryBean

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

the class WebServiceProtocol method doRefer.

@Override
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, URL url) throws RpcException {
    ClientProxyFactoryBean proxyFactoryBean = new ClientProxyFactoryBean();
    String servicePathPrefix = url.getParameter(SERVICE_PATH_PREFIX);
    if (!StringUtils.isEmpty(servicePathPrefix) && PROTOCOL_SERVER_SERVLET.equals(url.getParameter(PROTOCOL_SERVER))) {
        url = url.setPath(servicePathPrefix + "/" + url.getPath());
    }
    proxyFactoryBean.setAddress(url.setProtocol("http").toIdentityString());
    proxyFactoryBean.setServiceClass(serviceType);
    proxyFactoryBean.setBus(bus);
    T ref = (T) proxyFactoryBean.create();
    Client proxy = ClientProxy.getClient(ref);
    HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
    HTTPClientPolicy policy = new HTTPClientPolicy();
    policy.setConnectionTimeout(url.getParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT));
    policy.setReceiveTimeout(url.getParameter(TIMEOUT_KEY, DEFAULT_TIMEOUT));
    conduit.setClient(policy);
    return ref;
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) DEFAULT_TIMEOUT(org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT) PROTOCOL_SERVER_SERVLET(org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_SERVER_SERVLET) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) Client(org.apache.cxf.endpoint.Client)

Example 33 with ClientProxyFactoryBean

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

the class ExceptionTest method testHeaders.

@Test
public void testHeaders() throws Exception {
    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    proxyFac.setAddress("local://ExceptionService");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());
    ExceptionService client = proxyFac.create(ExceptionService.class);
    try {
        client.sayHiWithException();
        fail("Must throw exception!");
    } catch (HelloException e) {
    // nothing
    }
    // check to make sure the fault is an element
    Document wsdl = getWSDLDocument("ExceptionService");
    addNamespace("tns", "http://exception.aegis.cxf.apache.org");
    assertValid("//wsdl:message[@name='HelloException']/wsdl:part[@name='HelloException']" + "[@element='tns:String']", wsdl);
}
Also used : ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) Document(org.w3c.dom.Document) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 34 with ClientProxyFactoryBean

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

the class ExceptionInheritanceTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    AegisContext globalContext = new AegisContext();
    globalContext.setWriteXsiTypes(true);
    Set<String> l = new HashSet<>();
    l.add(SimpleBean.class.getName());
    l.add(WS1ExtendedException.class.getName());
    globalContext.setRootClassNames(l);
    AegisDatabinding binding = new AegisDatabinding();
    binding.setAegisContext(globalContext);
    ClientProxyFactoryBean pf = new ClientProxyFactoryBean();
    setupAegis(pf.getClientFactoryBean(), binding);
    pf.getServiceFactory().setProperties(props);
    pf.setAddress("local://WS1");
    pf.setProperties(props);
    client = pf.create(WS1.class);
    Server server = createService(WS1.class, new WS1Impl(), "WS1", binding);
    server.getEndpoint().getService().setInvoker(new BeanInvoker(new WS1Impl()));
}
Also used : WS1Impl(org.apache.cxf.aegis.inheritance.ws1.impl.WS1Impl) WS1(org.apache.cxf.aegis.inheritance.ws1.WS1) Server(org.apache.cxf.endpoint.Server) SimpleBean(org.apache.cxf.aegis.services.SimpleBean) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) AegisContext(org.apache.cxf.aegis.AegisContext) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) WS1ExtendedException(org.apache.cxf.aegis.inheritance.ws1.WS1ExtendedException) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 35 with ClientProxyFactoryBean

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

the class DOMMappingTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    createService(DocumentService.class, "DocService");
    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    ReflectionServiceFactoryBean factory = new ReflectionServiceFactoryBean();
    factory.getServiceConfigurations().add(0, new org.apache.cxf.aegis.databinding.XFireCompatibilityServiceConfiguration());
    proxyFac.setServiceFactory(factory);
    proxyFac.setDataBinding(new AegisDatabinding());
    proxyFac.setAddress("local://DocService");
    proxyFac.setBus(getBus());
    Object proxyObj = proxyFac.create(IDocumentService.class);
    docClient = (IDocumentService) proxyObj;
    Client client = ClientProxy.getClient(proxyObj);
    ClientImpl clientImpl = (ClientImpl) client;
    clientImpl.setSynchronousTimeout(1000000000);
}
Also used : ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) ClientImpl(org.apache.cxf.endpoint.ClientImpl) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) Client(org.apache.cxf.endpoint.Client) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) Before(org.junit.Before)

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