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;
}
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();
}
}
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());
}
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");
}
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());
}
Aggregations