use of org.apache.cxf.jaxws.JaxWsClientProxy in project cxf by apache.
the class ClientMtomXopTest method createPort.
private <T> T createPort(QName serviceName, QName portName, Class<T> serviceEndpointInterface, boolean enableMTOM, boolean installInterceptors) throws Exception {
ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
Bus bus = getStaticBus();
serviceFactory.setBus(bus);
serviceFactory.setServiceName(serviceName);
serviceFactory.setServiceClass(serviceEndpointInterface);
serviceFactory.setWsdlURL(ClientMtomXopTest.class.getResource("/wsdl/mtom_xop.wsdl"));
Service service = serviceFactory.create();
EndpointInfo ei = service.getEndpointInfo(portName);
JaxWsEndpointImpl jaxwsEndpoint = new JaxWsEndpointImpl(bus, service, ei);
SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding(), jaxwsEndpoint);
jaxWsSoapBinding.setMTOMEnabled(enableMTOM);
if (installInterceptors) {
// jaxwsEndpoint.getBinding().getInInterceptors().add(new TestMultipartMessageInterceptor());
jaxwsEndpoint.getBinding().getOutInterceptors().add(new TestAttachmentOutInterceptor());
}
jaxwsEndpoint.getBinding().getInInterceptors().add(new LoggingInInterceptor());
jaxwsEndpoint.getBinding().getOutInterceptors().add(new LoggingOutInterceptor());
Client client = new ClientImpl(bus, jaxwsEndpoint);
InvocationHandler ih = new JaxWsClientProxy(client, jaxwsEndpoint.getJaxwsBinding());
Object obj = Proxy.newProxyInstance(serviceEndpointInterface.getClassLoader(), new Class[] { serviceEndpointInterface, BindingProvider.class }, ih);
updateAddressPort(obj, PORT);
return serviceEndpointInterface.cast(obj);
}
Aggregations