Search in sources :

Example 1 with TransportTubeFactory

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

the class SDODatabindingTestBase method invmSetup.

protected WebServiceFeature[] invmSetup(final URL wsdlURL, final Class sei, final Class seb, final QName serviceName, final QName portName) {
    DatabindingModeFeature dbmf = new DatabindingModeFeature("eclipselink.sdo");
    Class implementorClass = seb;
    boolean handlersSetInDD = false;
    Container container = Container.NONE;
    Map<String, SDDocumentSource> docs = new HashMap<String, SDDocumentSource>();
    SDDocumentSource primaryWSDL = SDDocumentSource.create(wsdlURL);
    docs.put(wsdlURL.toString(), primaryWSDL);
    ExternalMetadataFeature exm = ExternalMetadataFeature.builder().setReader(new com.sun.xml.ws.model.ReflectAnnotationReader() {

        public <A extends Annotation> A getAnnotation(final Class<A> annType, final Class<?> cls) {
            if (WebService.class.equals(annType)) {
                final WebService ws = cls.getAnnotation(WebService.class);
                return (A) new jakarta.jws.WebService() {

                    public Class<? extends Annotation> annotationType() {
                        return WebService.class;
                    }

                    @Override
                    public String endpointInterface() {
                        return sei.getName();
                    }

                    @Override
                    public String name() {
                        return (ws != null) ? ws.name() : null;
                    }

                    @Override
                    public String portName() {
                        return (ws != null) ? ws.portName() : null;
                    }

                    @Override
                    public String serviceName() {
                        return (ws != null) ? ws.serviceName() : null;
                    }

                    @Override
                    public String targetNamespace() {
                        return (ws != null) ? ws.targetNamespace() : null;
                    }

                    @Override
                    public String wsdlLocation() {
                        return (ws != null) ? ws.wsdlLocation() : null;
                    }
                };
            }
            return cls.getAnnotation(annType);
        }
    }).build();
    BindingID bindingID = BindingID.parse(implementorClass);
    WSBinding binding = bindingID.createBinding(dbmf, exm);
    final WSEndpoint<?> endpoint = WSEndpoint.create(implementorClass, !handlersSetInDD, null, serviceName, portName, container, binding, primaryWSDL, docs.values(), XmlUtil.createEntityResolver(null), false);
    ComponentFeature cf = 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 InVmTransportTube(context.getCodec(), context.getBinding(), wsdlURL, endpoint);
                    }
                };
            return null;
        }
    });
    WebServiceFeature[] f = { dbmf, cf };
    return f;
}
Also used : WSBinding(com.sun.xml.ws.api.WSBinding) Tube(com.sun.xml.ws.api.pipe.Tube) HashMap(java.util.HashMap) WebService(jakarta.jws.WebService) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) BindingID(com.sun.xml.ws.api.BindingID) TransportTubeFactory(com.sun.xml.ws.api.pipe.TransportTubeFactory) Container(com.sun.xml.ws.api.server.Container) SDDocumentSource(com.sun.xml.ws.api.server.SDDocumentSource) Annotation(java.lang.annotation.Annotation) ExternalMetadataFeature(com.oracle.webservices.api.databinding.ExternalMetadataFeature) WebService(jakarta.jws.WebService) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) ComponentFeature(com.sun.xml.ws.api.ComponentFeature) ClientTubeAssemblerContext(com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)

Example 2 with TransportTubeFactory

use of com.sun.xml.ws.api.pipe.TransportTubeFactory 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 3 with TransportTubeFactory

use of com.sun.xml.ws.api.pipe.TransportTubeFactory 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

ComponentFeature (com.sun.xml.ws.api.ComponentFeature)3 ClientTubeAssemblerContext (com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)3 TransportTubeFactory (com.sun.xml.ws.api.pipe.TransportTubeFactory)3 BindingID (com.sun.xml.ws.api.BindingID)2 Packet (com.sun.xml.ws.api.message.Packet)2 NextAction (com.sun.xml.ws.api.pipe.NextAction)2 Tube (com.sun.xml.ws.api.pipe.Tube)2 Echo (com.sun.xml.ws.client.test.Echo)2 EchoService (com.sun.xml.ws.client.test.EchoService)2 NumbersRequest (com.sun.xml.ws.client.test.NumbersRequest)2 WebServiceException (jakarta.xml.ws.WebServiceException)2 URL (java.net.URL)2 DatabindingModeFeature (com.oracle.webservices.api.databinding.DatabindingModeFeature)1 ExternalMetadataFeature (com.oracle.webservices.api.databinding.ExternalMetadataFeature)1 WSBinding (com.sun.xml.ws.api.WSBinding)1 ServerTubeAssemblerContext (com.sun.xml.ws.api.pipe.ServerTubeAssemblerContext)1 TubelineAssembler (com.sun.xml.ws.api.pipe.TubelineAssembler)1 TubelineAssemblerFactory (com.sun.xml.ws.api.pipe.TubelineAssemblerFactory)1 Container (com.sun.xml.ws.api.server.Container)1 SDDocumentSource (com.sun.xml.ws.api.server.SDDocumentSource)1