Search in sources :

Example 6 with ClientTubeAssemblerContext

use of com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext in project metro-jax-ws by eclipse-ee4j.

the class TubelineAssemblerFactoryImplTest method getClientContext.

private ClientTubeAssemblerContext getClientContext(final BindingID bindingId, final Container container) {
    final WSBinding binding = bindingId.createBinding();
    final EndpointAddress address = new EndpointAddress(ADDRESS_URL);
    final WSDLPort port = null;
    final QName serviceName = new QName(NAMESPACE, "Service1Service");
    WSService service = WSService.create(serviceName);
    final QName portName = new QName(NAMESPACE, "Service1Port");
    // Corresponds to Service.addPort(portName, bindingId, address)
    service.addPort(portName, bindingId.toString(), ADDRESS_URL.toString());
    final WSPortInfo portInfo = ((WSServiceDelegate) service).safeGetPort(portName);
    WSBindingProvider wsbp = new WSBindingProvider() {

        public void setOutboundHeaders(List<Header> headers) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setOutboundHeaders(Header... headers) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setOutboundHeaders(Object... headers) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public List<Header> getInboundHeaders() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setAddress(String address) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public WSEndpointReference getWSEndpointReference() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public WSPortInfo getPortInfo() {
            return portInfo;
        }

        public Map<String, Object> getRequestContext() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Map<String, Object> getResponseContext() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Binding getBinding() {
            return binding;
        }

        public EndpointReference getEndpointReference() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void close() throws IOException {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public ManagedObjectManager getManagedObjectManager() {
            return null;
        }

        public Set<Component> getComponents() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public <S> S getSPI(Class<S> type) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    };
    final ClientTubeAssemblerContext context = new ClientTubeAssemblerContext(address, port, wsbp, binding, container, ((BindingImpl) binding).createCodec(), null, null);
    return context;
}
Also used : WSBinding(com.sun.xml.ws.api.WSBinding) QName(javax.xml.namespace.QName) WSService(com.sun.xml.ws.api.WSService) WSPortInfo(com.sun.xml.ws.api.client.WSPortInfo) WSDLPort(com.sun.xml.ws.api.model.wsdl.WSDLPort) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) EndpointReference(jakarta.xml.ws.EndpointReference) Header(com.sun.xml.ws.api.message.Header) WSServiceDelegate(com.sun.xml.ws.client.WSServiceDelegate) WSBindingProvider(com.sun.xml.ws.developer.WSBindingProvider) List(java.util.List) Component(com.sun.xml.ws.api.Component) ClientTubeAssemblerContext(com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext) EndpointAddress(com.sun.xml.ws.api.EndpointAddress)

Example 7 with ClientTubeAssemblerContext

use of com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext in project metro-jax-ws by eclipse-ee4j.

the class TubelineAssemblerFactoryImplTest method testDispatch.

/**
 * Execute a sequence that corresponds to:
 * <pre>
 *   Service.createService(null, serviceName);
 *   Service.addPort(portName, bindingId, address);
 * </pre>
 */
private Tube testDispatch(String configFileName) throws PolicyException {
    final URL wsdlLocation = null;
    final QName serviceName = new QName(NAMESPACE, "Service1Service");
    // Corresponds to Service.createService(wsdlLocation, serviceName)
    final WSServiceDelegate serviceDelegate = new WSServiceDelegate(wsdlLocation, serviceName, Service.class);
    final QName portName = new QName(NAMESPACE, "Service1Port");
    final BindingID bindingId = BindingID.SOAP11_HTTP;
    // Corresponds to Service.addPort(portName, bindingId, address)
    serviceDelegate.addPort(portName, bindingId.toString(), ADDRESS_URL.toString());
    final EndpointAddress address = new EndpointAddress(ADDRESS_URL);
    final WSDLPort port = null;
    final WSPortInfo portInfo = serviceDelegate.safeGetPort(portName);
    final WSBinding binding = bindingId.createBinding(new AddressingFeature(true));
    final Container container = MockupMetroConfigLoader.createMockupContainer("tubes-config/" + configFileName);
    WSBindingProvider wsbp = new WSBindingProvider() {

        public void setOutboundHeaders(List<Header> headers) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setOutboundHeaders(Header... headers) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setOutboundHeaders(Object... headers) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public List<Header> getInboundHeaders() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setAddress(String address) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public WSEndpointReference getWSEndpointReference() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public WSPortInfo getPortInfo() {
            return portInfo;
        }

        public Map<String, Object> getRequestContext() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Map<String, Object> getResponseContext() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Binding getBinding() {
            return binding;
        }

        public EndpointReference getEndpointReference() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void close() throws IOException {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public ManagedObjectManager getManagedObjectManager() {
            return null;
        }

        public Set<Component> getComponents() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public <S> S getSPI(Class<S> type) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    };
    final ClientTubeAssemblerContext context = new ClientTubeAssemblerContext(address, port, wsbp, binding, container, ((BindingImpl) binding).createCodec(), null, null);
    return getAssembler(bindingId).createClient(context);
}
Also used : WSBinding(com.sun.xml.ws.api.WSBinding) AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) QName(javax.xml.namespace.QName) BindingID(com.sun.xml.ws.api.BindingID) URL(java.net.URL) WSPortInfo(com.sun.xml.ws.api.client.WSPortInfo) WSDLPort(com.sun.xml.ws.api.model.wsdl.WSDLPort) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) EndpointReference(jakarta.xml.ws.EndpointReference) Container(com.sun.xml.ws.api.server.Container) Header(com.sun.xml.ws.api.message.Header) WSServiceDelegate(com.sun.xml.ws.client.WSServiceDelegate) WSBindingProvider(com.sun.xml.ws.developer.WSBindingProvider) List(java.util.List) Component(com.sun.xml.ws.api.Component) ClientTubeAssemblerContext(com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext) EndpointAddress(com.sun.xml.ws.api.EndpointAddress)

Example 8 with ClientTubeAssemblerContext

use of com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext in project metro-jax-ws by eclipse-ee4j.

the class ClientProxyTest method testNullResponseFromTube.

@SuppressWarnings("unchecked")
public void testNullResponseFromTube() throws Exception {
    URL wsdlURL = Thread.currentThread().getContextClassLoader().getResource("etc/EchoService.wsdl");
    EchoService srv = new EchoService(wsdlURL, new ComponentFeature(new com.sun.xml.ws.api.Component() {

        public <S> S getSPI(Class<S> spiType) {
            if (TransportTubeFactory.class.equals(spiType))
                return (S) new TransportTubeFactory() {

                    public Tube doCreate(ClientTubeAssemblerContext context) {
                        return new EchoTube();
                    }
                };
            if (TubelineAssemblerFactory.class.equals(spiType))
                return (S) new TubelineAssemblerFactory() {

                    public TubelineAssembler doCreate(BindingID bindingId) {
                        return new TubelineAssembler() {

                            public Tube createClient(ClientTubeAssemblerContext context) {
                                final Tube head = context.createTransportTube();
                                return new EchoTube() {

                                    public NextAction processRequest(Packet request) {
                                        NextAction na = new NextAction();
                                        na.invoke(head, request);
                                        return na;
                                    }

                                    public NextAction processResponse(Packet response) {
                                        NextAction na = new NextAction();
                                        na.returnWith(new Packet());
                                        return na;
                                    }
                                };
                            }

                            public Tube createServer(ServerTubeAssemblerContext context) {
                                return null;
                            }
                        };
                    }
                };
            return null;
        }
    }));
    Echo echo = srv.getEchoPort();
    try {
        int res = echo.add(new NumbersRequest());
        fail();
    } catch (Exception e) {
        assertFalse(e instanceof NullPointerException);
        assertTrue(e instanceof WebServiceException);
    }
    try {
        echo.echoString(new Holder(wsdlURL.toString()));
        fail();
    } catch (Exception e) {
        assertFalse(e instanceof NullPointerException);
        assertTrue(e instanceof WebServiceException);
    }
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) ServerTubeAssemblerContext(com.sun.xml.ws.api.pipe.ServerTubeAssemblerContext) NumbersRequest(com.sun.xml.ws.client.test.NumbersRequest) Tube(com.sun.xml.ws.api.pipe.Tube) WebServiceException(jakarta.xml.ws.WebServiceException) Echo(com.sun.xml.ws.client.test.Echo) EchoService(com.sun.xml.ws.client.test.EchoService) Holder(jakarta.xml.ws.Holder) TubelineAssembler(com.sun.xml.ws.api.pipe.TubelineAssembler) BindingID(com.sun.xml.ws.api.BindingID) URL(java.net.URL) WebServiceException(jakarta.xml.ws.WebServiceException) TransportTubeFactory(com.sun.xml.ws.api.pipe.TransportTubeFactory) TubelineAssemblerFactory(com.sun.xml.ws.api.pipe.TubelineAssemblerFactory) ComponentFeature(com.sun.xml.ws.api.ComponentFeature) NextAction(com.sun.xml.ws.api.pipe.NextAction) ClientTubeAssemblerContext(com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)

Example 9 with ClientTubeAssemblerContext

use of com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext in project metro-jax-ws by eclipse-ee4j.

the class ClientProxyTest method testNullResponseFromTransprt.

@SuppressWarnings("unchecked")
public void testNullResponseFromTransprt() throws Exception {
    URL wsdlURL = Thread.currentThread().getContextClassLoader().getResource("etc/EchoService.wsdl");
    EchoService srv = new EchoService(wsdlURL, new ComponentFeature(new com.sun.xml.ws.api.Component() {

        public <S> S getSPI(Class<S> spiType) {
            if (TransportTubeFactory.class.equals(spiType))
                return (S) new TransportTubeFactory() {

                    public Tube doCreate(ClientTubeAssemblerContext context) {
                        return new EchoTube() {

                            public NextAction processRequest(Packet request) {
                                NextAction na = new NextAction();
                                na.returnWith(new Packet());
                                return na;
                            }
                        };
                    }
                };
            return null;
        }
    }));
    Echo echo = srv.getEchoPort();
    try {
        int res = echo.add(new NumbersRequest());
        fail();
    } catch (Exception e) {
        assertFalse(e instanceof NullPointerException);
        assertTrue(e instanceof WebServiceException);
    }
    try {
        echo.echoString(new Holder<String>(wsdlURL.toString()));
        fail();
    } catch (Exception e) {
        assertFalse(e instanceof NullPointerException);
        assertTrue(e instanceof WebServiceException);
    }
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) NumbersRequest(com.sun.xml.ws.client.test.NumbersRequest) WebServiceException(jakarta.xml.ws.WebServiceException) Echo(com.sun.xml.ws.client.test.Echo) EchoService(com.sun.xml.ws.client.test.EchoService) URL(java.net.URL) WebServiceException(jakarta.xml.ws.WebServiceException) TransportTubeFactory(com.sun.xml.ws.api.pipe.TransportTubeFactory) ComponentFeature(com.sun.xml.ws.api.ComponentFeature) NextAction(com.sun.xml.ws.api.pipe.NextAction) ClientTubeAssemblerContext(com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)

Aggregations

ClientTubeAssemblerContext (com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)9 BindingID (com.sun.xml.ws.api.BindingID)6 WSBinding (com.sun.xml.ws.api.WSBinding)4 Tube (com.sun.xml.ws.api.pipe.Tube)4 Container (com.sun.xml.ws.api.server.Container)4 ComponentFeature (com.sun.xml.ws.api.ComponentFeature)3 Packet (com.sun.xml.ws.api.message.Packet)3 TransportTubeFactory (com.sun.xml.ws.api.pipe.TransportTubeFactory)3 WebServiceException (jakarta.xml.ws.WebServiceException)3 URL (java.net.URL)3 Component (com.sun.xml.ws.api.Component)2 EndpointAddress (com.sun.xml.ws.api.EndpointAddress)2 WSService (com.sun.xml.ws.api.WSService)2 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)2 WSPortInfo (com.sun.xml.ws.api.client.WSPortInfo)2 Header (com.sun.xml.ws.api.message.Header)2 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)2 NextAction (com.sun.xml.ws.api.pipe.NextAction)2 TubelineAssembler (com.sun.xml.ws.api.pipe.TubelineAssembler)2 BindingImpl (com.sun.xml.ws.binding.BindingImpl)2