Search in sources :

Example 26 with JaxWsProxyFactoryBean

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

the class ManagedConnectionImpl method getCXFConnection.

public synchronized Object getCXFConnection(Subject subject, ConnectionRequestInfo crInfo) throws ResourceException {
    CXFConnectionRequestInfo requestInfo = (CXFConnectionRequestInfo) crInfo;
    Class<?> serviceInterface = requestInfo.getInterface();
    ClassLoader orig = Thread.currentThread().getContextClassLoader();
    try {
        final ClientProxyFactoryBean factoryBean;
        if (isJaxWsServiceInterface(serviceInterface)) {
            factoryBean = new JaxWsProxyFactoryBean();
        } else {
            factoryBean = new ClientProxyFactoryBean();
        }
        factoryBean.setServiceClass(serviceInterface);
        if (requestInfo.getServiceName() != null) {
            factoryBean.getServiceFactory().setServiceName(requestInfo.getServiceName());
        }
        if (requestInfo.getPortName() != null) {
            factoryBean.getServiceFactory().setEndpointName(requestInfo.getPortName());
        }
        if (requestInfo.getWsdlLocation() != null) {
            factoryBean.getServiceFactory().setWsdlURL(requestInfo.getWsdlLocation());
        }
        if (requestInfo.getAddress() != null) {
            factoryBean.setAddress(requestInfo.getAddress());
        }
        Object obj = factoryBean.create();
        setSubject(subject);
        return createConnectionProxy(obj, requestInfo, subject);
    } catch (WebServiceException wse) {
        throw new ResourceAdapterInternalException(new Message("FAILED_TO_GET_CXF_CONNECTION", BUNDLE, requestInfo).toString(), wse);
    } finally {
        Thread.currentThread().setContextClassLoader(orig);
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Message(org.apache.cxf.common.i18n.Message) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) ResourceAdapterInternalException(org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException)

Example 27 with JaxWsProxyFactoryBean

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

the class StudentTest method testReturnMapDocLiteral.

@Test
public void testReturnMapDocLiteral() throws Exception {
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setServiceClass(StudentServiceDocLiteral.class);
    sf.setServiceBean(new StudentServiceDocLiteralImpl());
    sf.setAddress("local://StudentServiceDocLiteral");
    setupAegis(sf);
    Server server = sf.create();
    server.start();
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setAddress("local://StudentServiceDocLiteral");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());
    StudentServiceDocLiteral clientInterface = proxyFac.create(StudentServiceDocLiteral.class);
    Map<Long, Student> fullMap = clientInterface.getStudentsMap();
    assertNotNull(fullMap);
    Student one = fullMap.get(Long.valueOf(1));
    assertNotNull(one);
    assertEquals("Student1", one.getName());
}
Also used : Server(org.apache.cxf.endpoint.Server) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 28 with JaxWsProxyFactoryBean

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

the class StudentTest method testReturnMap.

@Test
public void testReturnMap() throws Exception {
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setServiceClass(StudentService.class);
    sf.setServiceBean(new StudentServiceImpl());
    sf.setAddress("local://StudentService");
    setupAegis(sf);
    Server server = sf.create();
    server.start();
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setAddress("local://StudentService");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());
    StudentService clientInterface = proxyFac.create(StudentService.class);
    Map<Long, Student> fullMap = clientInterface.getStudentsMap();
    assertNotNull(fullMap);
    Student one = fullMap.get(Long.valueOf(1));
    assertNotNull(one);
    assertEquals("Student1", one.getName());
    Map<String, ?> wildMap = clientInterface.getWildcardMap();
    assertEquals("valuestring", wildMap.get("keystring"));
}
Also used : Server(org.apache.cxf.endpoint.Server) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 29 with JaxWsProxyFactoryBean

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

the class MapsTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setServiceClass(MapTest.class);
    sf.setServiceBean(new MapTestImpl());
    sf.setAddress("local://MapTest");
    setupAegis(sf);
    server = sf.create();
    // server.getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
    // server.getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
    server.start();
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setAddress("local://MapTest");
    proxyFac.setServiceClass(MapTest.class);
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());
    clientInterface = (MapTest) proxyFac.create();
}
Also used : MapTestImpl(org.apache.cxf.aegis.type.map.fortest.MapTestImpl) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Before(org.junit.Before)

Example 30 with JaxWsProxyFactoryBean

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

the class AsyncHTTPConduitTest method testInvocationWithTransportId.

@Test
public void testInvocationWithTransportId() throws Exception {
    String address = "http://localhost:" + PORT + "/SoapContext/SoapPort";
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(Greeter.class);
    factory.setAddress(address);
    factory.setTransportId("http://cxf.apache.org/transports/http/http-client");
    Greeter greeter = factory.create(Greeter.class);
    String response = greeter.greetMe("test");
    assertEquals("Get a wrong response", "Hello test", response);
}
Also used : Greeter(org.apache.hello_world_soap_http.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) 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