Search in sources :

Example 6 with Container

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

the class DispatchImpl method invokeOneWay.

public final void invokeOneWay(T in) {
    Container old = ContainerResolver.getDefault().enterContainer(owner.getContainer());
    try {
        if (LOGGER.isLoggable(Level.FINE)) {
            dumpParam(in, "invokeOneWay(T)");
        }
        try {
            checkNullAllowed(in, requestContext, binding, mode);
            Packet request = createPacket(in);
            request.setState(Packet.State.ClientRequest);
            setProperties(request, false);
            process(request, requestContext, this);
        } catch (WebServiceException e) {
            // it could be a WebServiceException or a ProtocolException
            throw e;
        } catch (Throwable e) {
            // WebServiceException
            throw new WebServiceException(e);
        }
    } finally {
        ContainerResolver.getDefault().exitContainer(old);
    }
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Container(com.sun.xml.ws.api.server.Container) WebServiceException(jakarta.xml.ws.WebServiceException)

Example 7 with Container

use of com.sun.xml.ws.api.server.Container 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 8 with Container

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

the class ProviderImpl method createW3CEndpointReference.

public W3CEndpointReference createW3CEndpointReference(String address, QName interfaceName, QName serviceName, QName portName, List<Element> metadata, String wsdlDocumentLocation, List<Element> referenceParameters, List<Element> elements, Map<QName, String> attributes) {
    Container container = ContainerResolver.getInstance().getContainer();
    if (address == null) {
        if (serviceName == null || portName == null) {
            throw new IllegalStateException(ProviderApiMessages.NULL_ADDRESS_SERVICE_ENDPOINT());
        } else {
            // check if it is run in a Java EE Container and if so, get address using serviceName and portName
            Module module = container.getSPI(Module.class);
            if (module != null) {
                List<BoundEndpoint> beList = module.getBoundEndpoints();
                for (BoundEndpoint be : beList) {
                    WSEndpoint wse = be.getEndpoint();
                    if (wse.getServiceName().equals(serviceName) && wse.getPortName().equals(portName)) {
                        try {
                            address = be.getAddress().toString();
                        } catch (WebServiceException e) {
                        // May be the container does n't support this
                        // just ignore the exception
                        }
                        break;
                    }
                }
            }
            // address is still null? may be its not run in a JavaEE Container
            if (address == null)
                throw new IllegalStateException(ProviderApiMessages.NULL_ADDRESS());
        }
    }
    if ((serviceName == null) && (portName != null)) {
        throw new IllegalStateException(ProviderApiMessages.NULL_SERVICE());
    }
    // Validate Service and Port in WSDL
    String wsdlTargetNamespace = null;
    if (wsdlDocumentLocation != null) {
        try {
            EntityResolver er = XmlUtil.createDefaultCatalogResolver();
            URL wsdlLoc = new URL(wsdlDocumentLocation);
            WSDLModel wsdlDoc = RuntimeWSDLParser.parse(wsdlLoc, new StreamSource(wsdlLoc.toExternalForm()), er, true, container, ServiceFinder.find(WSDLParserExtension.class).toArray());
            if (serviceName != null) {
                WSDLService wsdlService = wsdlDoc.getService(serviceName);
                if (wsdlService == null)
                    throw new IllegalStateException(ProviderApiMessages.NOTFOUND_SERVICE_IN_WSDL(serviceName, wsdlDocumentLocation));
                if (portName != null) {
                    WSDLPort wsdlPort = wsdlService.get(portName);
                    if (wsdlPort == null)
                        throw new IllegalStateException(ProviderApiMessages.NOTFOUND_PORT_IN_WSDL(portName, serviceName, wsdlDocumentLocation));
                }
                wsdlTargetNamespace = serviceName.getNamespaceURI();
            } else {
                QName firstService = wsdlDoc.getFirstServiceName();
                wsdlTargetNamespace = firstService.getNamespaceURI();
            }
        } catch (Exception e) {
            throw new IllegalStateException(ProviderApiMessages.ERROR_WSDL(wsdlDocumentLocation), e);
        }
    }
    // wcf3.0/3.5 rejected empty metadata element.
    if (metadata != null && metadata.size() == 0) {
        metadata = null;
    }
    return new WSEndpointReference(AddressingVersion.fromSpecClass(W3CEndpointReference.class), address, serviceName, portName, interfaceName, metadata, wsdlDocumentLocation, wsdlTargetNamespace, referenceParameters, elements, attributes).toSpec(W3CEndpointReference.class);
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) StreamSource(javax.xml.transform.stream.StreamSource) WSDLModel(com.sun.xml.ws.api.model.wsdl.WSDLModel) EntityResolver(org.xml.sax.EntityResolver) BoundEndpoint(com.sun.xml.ws.api.server.BoundEndpoint) URL(java.net.URL) WebServiceException(jakarta.xml.ws.WebServiceException) JAXBException(jakarta.xml.bind.JAXBException) WSDLPort(com.sun.xml.ws.api.model.wsdl.WSDLPort) Container(com.sun.xml.ws.api.server.Container) WSEndpoint(com.sun.xml.ws.api.server.WSEndpoint) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) WSDLService(com.sun.xml.ws.api.model.wsdl.WSDLService) Module(com.sun.xml.ws.api.server.Module)

Example 9 with Container

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

the class Fiber method run.

/**
 * DO NOT CALL THIS METHOD. This is an implementation detail
 * of {@link Fiber}.
 */
@Deprecated
@Override
public void run() {
    Container old = ContainerResolver.getDefault().enterContainer(owner.getContainer());
    try {
        assert !synchronous;
        // doRun returns true to indicate an early exit from fiber processing
        if (!doRun()) {
            if (startedSync && suspendedCount == 0 && (next != null || contsSize > 0)) {
                // We bailed out of running this fiber we started as sync, and now
                // want to finish running it async
                startedSync = false;
                // Start back up as an async fiber
                dumpFiberContext("restarting (async) after startSync");
                owner.addRunnable(this);
            } else {
                completionCheck();
            }
        }
    } finally {
        ContainerResolver.getDefault().exitContainer(old);
    }
}
Also used : Container(com.sun.xml.ws.api.server.Container)

Example 10 with Container

use of com.sun.xml.ws.api.server.Container 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)

Aggregations

Container (com.sun.xml.ws.api.server.Container)14 BindingID (com.sun.xml.ws.api.BindingID)4 ClientTubeAssemblerContext (com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)4 WSBinding (com.sun.xml.ws.api.WSBinding)2 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)2 Packet (com.sun.xml.ws.api.message.Packet)2 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)2 Tube (com.sun.xml.ws.api.pipe.Tube)2 WebServiceException (jakarta.xml.ws.WebServiceException)2 URL (java.net.URL)2 QName (javax.xml.namespace.QName)2 DatabindingModeFeature (com.oracle.webservices.api.databinding.DatabindingModeFeature)1 ExternalMetadataFeature (com.oracle.webservices.api.databinding.ExternalMetadataFeature)1 Component (com.sun.xml.ws.api.Component)1 ComponentFeature (com.sun.xml.ws.api.ComponentFeature)1 EndpointAddress (com.sun.xml.ws.api.EndpointAddress)1 ResourceLoader (com.sun.xml.ws.api.ResourceLoader)1 WSPortInfo (com.sun.xml.ws.api.client.WSPortInfo)1 Header (com.sun.xml.ws.api.message.Header)1 WSDLModel (com.sun.xml.ws.api.model.wsdl.WSDLModel)1