Search in sources :

Example 1 with JaxWsClientProxy

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);
}
Also used : Bus(org.apache.cxf.Bus) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) Service(org.apache.cxf.service.Service) SOAPBinding(javax.xml.ws.soap.SOAPBinding) ClientImpl(org.apache.cxf.endpoint.ClientImpl) InvocationHandler(java.lang.reflect.InvocationHandler) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) JaxWsEndpointImpl(org.apache.cxf.jaxws.support.JaxWsEndpointImpl) JaxWsClientProxy(org.apache.cxf.jaxws.JaxWsClientProxy) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) SOAPBindingImpl(org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl) Client(org.apache.cxf.endpoint.Client) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)

Aggregations

InvocationHandler (java.lang.reflect.InvocationHandler)1 SOAPBinding (javax.xml.ws.soap.SOAPBinding)1 Bus (org.apache.cxf.Bus)1 Client (org.apache.cxf.endpoint.Client)1 ClientImpl (org.apache.cxf.endpoint.ClientImpl)1 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)1 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)1 JaxWsClientProxy (org.apache.cxf.jaxws.JaxWsClientProxy)1 SOAPBindingImpl (org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl)1 JaxWsEndpointImpl (org.apache.cxf.jaxws.support.JaxWsEndpointImpl)1 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)1 Service (org.apache.cxf.service.Service)1 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)1 ReflectionServiceFactoryBean (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)1