Search in sources :

Example 51 with JaxWsProxyFactoryBean

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

the class ResourceTest method createClient.

protected Resource createClient(ReferenceParametersType refParams) {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setBus(bus);
    factory.setServiceClass(Resource.class);
    factory.setAddress(RESOURCE_LOCAL_ADDRESS);
    Resource proxy = (Resource) factory.create();
    // Add reference parameters
    AddressingProperties addrProps = new AddressingProperties();
    EndpointReferenceType endpoint = new EndpointReferenceType();
    endpoint.setReferenceParameters(refParams);
    endpoint.setAddress(ContextUtils.getAttributedURI(RESOURCE_ADDRESS));
    addrProps.setTo(endpoint);
    ((BindingProvider) proxy).getRequestContext().put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addrProps);
    return proxy;
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Resource(org.apache.cxf.ws.transfer.resource.Resource) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties)

Example 52 with JaxWsProxyFactoryBean

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

the class ClientServerSwaTest method testSwa.

@Test
public void testSwa() throws Exception {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setWsdlLocation("classpath:/swa-mime_jms.wsdl");
    factory.setTransportId(SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID);
    factory.setServiceName(new QName("http://cxf.apache.org/swa", "SwAService"));
    factory.setEndpointName(new QName("http://cxf.apache.org/swa", "SwAServiceJMSPort"));
    factory.setAddress(ADDRESS + broker.getEncodedBrokerURL());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    SwAService port = factory.create(SwAService.class);
    Holder<String> textHolder = new Holder<>();
    Holder<DataHandler> data = new Holder<>();
    ByteArrayDataSource source = new ByteArrayDataSource("foobar".getBytes(), "application/octet-stream");
    DataHandler handler = new DataHandler(source);
    data.value = handler;
    textHolder.value = "Hi";
    port.echoData(textHolder, data);
    InputStream bis = null;
    bis = data.value.getDataSource().getInputStream();
    byte[] b = new byte[10];
    bis.read(b, 0, 10);
    String string = IOUtils.newStringFromBytes(b);
    assertEquals("testfoobar", string);
    assertEquals("Hi", textHolder.value);
    if (port instanceof Closeable) {
        ((Closeable) port).close();
    }
}
Also used : QName(javax.xml.namespace.QName) InputStream(java.io.InputStream) Holder(javax.xml.ws.Holder) Closeable(java.io.Closeable) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) DataHandler(javax.activation.DataHandler) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) Test(org.junit.Test)

Example 53 with JaxWsProxyFactoryBean

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

the class JMSTransactionTest method createGreeterProxy.

private Greeter createGreeterProxy() throws Exception {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setBus(bus);
    factory.getFeatures().add(cff);
    factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
    factory.setServiceClass(Greeter.class);
    factory.setAddress(SERVICE_ADDRESS);
    return (Greeter) markForClose(factory.create());
}
Also used : Greeter(org.apache.hello_world_doc_lit.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean)

Example 54 with JaxWsProxyFactoryBean

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

the class WSAClientServerTest method testNoWsaFeature.

@Test
public void testNoWsaFeature() throws Exception {
    ByteArrayOutputStream input = setupInLogging();
    ByteArrayOutputStream output = setupOutLogging();
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(AddNumbersPortType.class);
    factory.setAddress("http://localhost:" + PORT + "/jaxws/add");
    AddNumbersPortType port = (AddNumbersPortType) factory.create();
    assertEquals(3, port.addNumbers(1, 2));
    assertLogNotContains(output.toString(), "//wsa:Address");
    assertLogNotContains(input.toString(), "//wsa:RelatesTo");
}
Also used : JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 55 with JaxWsProxyFactoryBean

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

the class WSAFeatureXmlTest method testClientProxyFactory.

@Test
public void testClientProxyFactory() {
    JaxWsProxyFactoryBean cf = new JaxWsProxyFactoryBean();
    cf.setAddress("http://localhost:" + PORT + "/test");
    cf.setServiceClass(Greeter.class);
    cf.setBus(getBus());
    Configurer c = getBus().getExtension(Configurer.class);
    c.configureBean("client.proxyFactory", cf);
    Greeter greeter = (Greeter) cf.create();
    Client client = ClientProxy.getClient(greeter);
    checkAddressInterceptors(client.getInInterceptors());
}
Also used : Greeter(org.apache.hello_world_soap_http.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Configurer(org.apache.cxf.configuration.Configurer) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test) AbstractCXFTest(org.apache.cxf.test.AbstractCXFTest)

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