Search in sources :

Example 26 with WebServiceException

use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.

the class Stub method createPipeline.

/**
 * Creates a new pipeline for the given port name.
 */
private Tube createPipeline(WSPortInfo portInfo, WSBinding binding) {
    // Check all required WSDL extensions are understood
    checkAllWSDLExtensionsUnderstood(portInfo, binding);
    SEIModel seiModel = null;
    Class sei = null;
    if (portInfo instanceof SEIPortInfo) {
        SEIPortInfo sp = (SEIPortInfo) portInfo;
        seiModel = sp.model;
        sei = sp.sei;
    }
    BindingID bindingId = portInfo.getBindingId();
    TubelineAssembler assembler = TubelineAssemblerFactory.create(Thread.currentThread().getContextClassLoader(), bindingId, owner.getContainer());
    if (assembler == null) {
        // TODO: i18n
        throw new WebServiceException("Unable to process bindingID=" + bindingId);
    }
    return assembler.createClient(new ClientTubeAssemblerContext(portInfo.getEndpointAddress(), portInfo.getPort(), this, binding, owner.getContainer(), ((BindingImpl) binding).createCodec(), seiModel, sei));
}
Also used : SEIModel(com.sun.xml.ws.api.model.SEIModel) BindingImpl(com.sun.xml.ws.binding.BindingImpl) WebServiceException(jakarta.xml.ws.WebServiceException) TubelineAssembler(com.sun.xml.ws.api.pipe.TubelineAssembler) BindingID(com.sun.xml.ws.api.BindingID) ClientTubeAssemblerContext(com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)

Example 27 with WebServiceException

use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.

the class Stub method getWSEndpointReference.

@Override
public final WSEndpointReference getWSEndpointReference() {
    if (binding.getBindingID().equals(HTTPBinding.HTTP_BINDING)) {
        throw new java.lang.UnsupportedOperationException(ClientMessages.UNSUPPORTED_OPERATION("BindingProvider.getEndpointReference(Class<T> class)", "XML/HTTP Binding", "SOAP11 or SOAP12 Binding"));
    }
    if (endpointReference != null) {
        return endpointReference;
    }
    String eprAddress = requestContext.getEndpointAddress().toString();
    QName portTypeName = null;
    String wsdlAddress = null;
    List<WSEndpointReference.EPRExtension> wsdlEPRExtensions = new ArrayList<>();
    if (wsdlPort != null) {
        portTypeName = wsdlPort.getBinding().getPortTypeName();
        wsdlAddress = eprAddress + "?wsdl";
        // gather EPRExtensions specified in WSDL.
        try {
            WSEndpointReference wsdlEpr = wsdlPort.getEPR();
            if (wsdlEpr != null) {
                for (WSEndpointReference.EPRExtension extnEl : wsdlEpr.getEPRExtensions()) {
                    wsdlEPRExtensions.add(new WSEPRExtension(XMLStreamBuffer.createNewBufferFromXMLStreamReader(extnEl.readAsXMLStreamReader()), extnEl.getQName()));
                }
            }
        } catch (XMLStreamException ex) {
            throw new WebServiceException(ex);
        }
    }
    AddressingVersion av = AddressingVersion.W3C;
    this.endpointReference = new WSEndpointReference(av, eprAddress, getServiceName(), getPortName(), portTypeName, null, wsdlAddress, null, wsdlEPRExtensions, null);
    return this.endpointReference;
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) XMLStreamException(javax.xml.stream.XMLStreamException) AddressingVersion(com.sun.xml.ws.api.addressing.AddressingVersion) WSEPRExtension(com.sun.xml.ws.addressing.WSEPRExtension) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) WSEPRExtension(com.sun.xml.ws.addressing.WSEPRExtension)

Example 28 with WebServiceException

use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.

the class Stub method processAsync.

/**
 * Passes a message through a {@link Tube}line for processing. The processing happens
 * asynchronously and when the response is available, Fiber.CompletionCallback is
 * called. The processing could happen on multiple threads.
 *
 * <p>
 * Unlike {@link Tube} instances,
 * this method is thread-safe and can be invoked from
 * multiple threads concurrently.
 *
 * @param receiver       The {@link Response} implementation
 * @param request         The message to be sent to the server
 * @param requestContext The {@link RequestContext} when this invocation is originally scheduled.
 *                       This must be the same object as {@link #requestContext} for synchronous
 *                       invocations, but for asynchronous invocations, it needs to be a snapshot
 *                       captured at the point of invocation, to correctly satisfy the spec requirement.
 * @param completionCallback Once the processing is done, the callback is invoked.
 */
protected final void processAsync(AsyncResponseImpl<?> receiver, Packet request, RequestContext requestContext, final Fiber.CompletionCallback completionCallback) {
    // fill in Packet
    request.component = this;
    configureRequestPacket(request, requestContext);
    final Pool<Tube> pool = tubes;
    if (pool == null) {
        // TODO: i18n
        throw new WebServiceException("close method has already been invoked");
    }
    final Fiber fiber = engine.createFiber();
    configureFiber(fiber);
    receiver.setCancelable(fiber);
    // check race condition on cancel
    if (receiver.isCancelled()) {
        return;
    }
    FiberContextSwitchInterceptorFactory fcsif = owner.getSPI(FiberContextSwitchInterceptorFactory.class);
    if (fcsif != null) {
        fiber.addInterceptor(fcsif.create());
    }
    // then send it away!
    final Tube tube = pool.take();
    Fiber.CompletionCallback fiberCallback = new Fiber.CompletionCallback() {

        @Override
        public void onCompletion(@NotNull Packet response) {
            pool.recycle(tube);
            completionCallback.onCompletion(response);
        }

        @Override
        public void onCompletion(@NotNull Throwable error) {
            // let's not reuse tubes as they might be in a wrong state, so not
            // calling pool.recycle()
            completionCallback.onCompletion(error);
        }
    };
    // Check for SyncStartForAsyncInvokeFeature
    fiber.start(tube, request, fiberCallback, getBinding().isFeatureEnabled(SyncStartForAsyncFeature.class) && !requestContext.containsKey(PREVENT_SYNC_START_FOR_ASYNC_INVOKE));
}
Also used : FiberContextSwitchInterceptorFactory(com.sun.xml.ws.api.pipe.FiberContextSwitchInterceptorFactory) Packet(com.sun.xml.ws.api.message.Packet) Tube(com.sun.xml.ws.api.pipe.Tube) WebServiceException(jakarta.xml.ws.WebServiceException) Fiber(com.sun.xml.ws.api.pipe.Fiber) NotNull(com.sun.istack.NotNull)

Example 29 with WebServiceException

use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.

the class WSServiceDelegate method getPort.

@Override
public <T> T getPort(Class<T> portInterface, WebServiceFeature... features) {
    // get the portType from SEI
    QName portTypeName = RuntimeModeler.getPortTypeName(portInterface, getMetadadaReader(new WebServiceFeatureList(features), portInterface.getClassLoader()));
    WSDLService tmpWsdlService = this.wsdlService;
    if (tmpWsdlService == null) {
        // assigning it to local variable and not setting it back to this.wsdlService intentionally
        // as we don't want to include the service instance with information gathered from sei
        tmpWsdlService = getWSDLModelfromSEI(portInterface);
        // still null? throw error need wsdl metadata to create a proxy
        if (tmpWsdlService == null) {
            throw new WebServiceException(ProviderApiMessages.NO_WSDL_NO_PORT(portInterface.getName()));
        }
    }
    // get the first port corresponding to the SEI
    WSDLPort port = tmpWsdlService.getMatchingPort(portTypeName);
    if (port == null) {
        throw new WebServiceException(ClientMessages.UNDEFINED_PORT_TYPE(portTypeName));
    }
    QName portName = port.getName();
    return getPort(portName, portInterface, features);
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) WSDLService(com.sun.xml.ws.api.model.wsdl.WSDLService) WebServiceFeatureList(com.sun.xml.ws.binding.WebServiceFeatureList) WSDLPort(com.sun.xml.ws.api.model.wsdl.WSDLPort)

Example 30 with WebServiceException

use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.

the class WSServiceDelegate method getWSDLModelfromSEI.

private WSDLService getWSDLModelfromSEI(final Class sei) {
    WebService ws = AccessController.doPrivileged(new PrivilegedAction<>() {

        public WebService run() {
            return (WebService) sei.getAnnotation(WebService.class);
        }
    });
    if (ws == null || ws.wsdlLocation().equals(""))
        return null;
    String wsdlLocation = ws.wsdlLocation();
    wsdlLocation = JAXWSUtils.absolutize(JAXWSUtils.getFileOrURLName(wsdlLocation));
    Source wsdl = new StreamSource(wsdlLocation);
    WSDLService service = null;
    try {
        URL url = wsdl.getSystemId() == null ? null : new URL(wsdl.getSystemId());
        WSDLModel model = parseWSDL(url, wsdl, sei);
        service = model.getService(this.serviceName);
        if (service == null)
            throw new WebServiceException(ClientMessages.INVALID_SERVICE_NAME(this.serviceName, buildNameList(model.getServices().keySet())));
    } catch (MalformedURLException e) {
        throw new WebServiceException(ClientMessages.INVALID_WSDL_URL(wsdl.getSystemId()));
    }
    return service;
}
Also used : MalformedURLException(java.net.MalformedURLException) WebServiceException(jakarta.xml.ws.WebServiceException) WebService(jakarta.jws.WebService) StreamSource(javax.xml.transform.stream.StreamSource) WSDLModel(com.sun.xml.ws.api.model.wsdl.WSDLModel) WSDLService(com.sun.xml.ws.api.model.wsdl.WSDLService) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) URL(java.net.URL)

Aggregations

WebServiceException (jakarta.xml.ws.WebServiceException)386 QName (javax.xml.namespace.QName)49 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)36 SOAPException (jakarta.xml.soap.SOAPException)33 JAXBException (jakarta.xml.bind.JAXBException)30 Node (org.w3c.dom.Node)28 JAXBContext (jakarta.xml.bind.JAXBContext)27 IOException (java.io.IOException)26 SOAPMessage (jakarta.xml.soap.SOAPMessage)25 XMLStreamException (javax.xml.stream.XMLStreamException)25 Source (javax.xml.transform.Source)23 ProtocolException (jakarta.xml.ws.ProtocolException)20 Dispatch (jakarta.xml.ws.Dispatch)19 MalformedURLException (java.net.MalformedURLException)19 MessageContext (jakarta.xml.ws.handler.MessageContext)17 Map (java.util.Map)17 URL (java.net.URL)16 StreamSource (javax.xml.transform.stream.StreamSource)16 HandlerTracker (fromwsdl.handler.common.HandlerTracker)14 HandlerTracker (handler.handler_processing.common.HandlerTracker)14