Search in sources :

Example 1 with WSService

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

the class ProviderImpl method getPort.

public <T> T getPort(EndpointReference endpointReference, Class<T> clazz, WebServiceFeature... webServiceFeatures) {
    /*
        final @NotNull MemberSubmissionEndpointReference msepr =
                EndpointReferenceUtil.transform(MemberSubmissionEndpointReference.class, endpointReference);
                WSService service = new WSServiceDelegate(msepr.toWSDLSource(), msepr.serviceName.name, Service.class);
                */
    if (endpointReference == null)
        throw new WebServiceException(ProviderApiMessages.NULL_EPR());
    WSEndpointReference wsepr = new WSEndpointReference(endpointReference);
    WSEndpointReference.Metadata metadata = wsepr.getMetaData();
    WSService service;
    if (metadata.getWsdlSource() != null)
        service = (WSService) createServiceDelegate(metadata.getWsdlSource(), metadata.getServiceName(), Service.class);
    else
        throw new WebServiceException("WSDL metadata is missing in EPR");
    return service.getPort(wsepr, clazz, webServiceFeatures);
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) WSService(com.sun.xml.ws.api.WSService) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) WSDLService(com.sun.xml.ws.api.model.wsdl.WSDLService) WSService(com.sun.xml.ws.api.WSService) Service(jakarta.xml.ws.Service)

Example 2 with WSService

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

the class NonAnonymousResponseProcessor method process.

/**
 * Send a response to a non-anonymous address. Also closes the transport back channel
 * of {@link Packet} if it's not closed already.
 *
 * @param packet
 *      The response from our server, which will be delivered to the destination.
 * @return The response packet that should be used to complete the tubeline response processing
 */
public Packet process(Packet packet) {
    Fiber.CompletionCallback fiberCallback = null;
    Fiber currentFiber = Fiber.getCurrentIfSet();
    if (currentFiber != null) {
        // Link completion of the current fiber to the new fiber that will
        // deliver the async response. This allows access to the response
        // packet that may be generated by sending a new message for the
        // current async response.
        final Fiber.CompletionCallback currentFiberCallback = currentFiber.getCompletionCallback();
        if (currentFiberCallback != null) {
            fiberCallback = new Fiber.CompletionCallback() {

                public void onCompletion(@NotNull Packet response) {
                    currentFiberCallback.onCompletion(response);
                }

                public void onCompletion(@NotNull Throwable error) {
                    currentFiberCallback.onCompletion(error);
                }
            };
            currentFiber.setCompletionCallback(null);
        }
    }
    // we need to assemble a pipeline to talk to this endpoint.
    WSEndpoint<?> endpoint = packet.endpoint;
    WSBinding binding = endpoint.getBinding();
    Tube transport = TransportTubeFactory.create(Thread.currentThread().getContextClassLoader(), new ClientTubeAssemblerContext(packet.endpointAddress, endpoint.getPort(), (WSService) null, binding, endpoint.getContainer(), ((BindingImpl) binding).createCodec(), null, null));
    Fiber fiber = endpoint.getEngine().createFiber();
    fiber.start(transport, packet, fiberCallback);
    // then we'll proceed the rest like one-way.
    Packet copy = packet.copy(false);
    copy.endpointAddress = null;
    return copy;
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) WSBinding(com.sun.xml.ws.api.WSBinding) BindingImpl(com.sun.xml.ws.binding.BindingImpl) Tube(com.sun.xml.ws.api.pipe.Tube) WSService(com.sun.xml.ws.api.WSService) Fiber(com.sun.xml.ws.api.pipe.Fiber) ClientTubeAssemblerContext(com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)

Example 3 with WSService

use of com.sun.xml.ws.api.WSService 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 4 with WSService

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

the class AddNumbersClient method testCustomFault1.

/**
 * This test tests the functionality of OnewayFeature and AddressingFeature the way it being used in WS-AT implementation
 * In WS-AT impl, Server-side has to send fault messages to predefined coordinator and this test replicates that usage.
 *
 * @throws Exception
 */
public void testCustomFault1() throws Exception {
    SOAPFault fault = SOAPFactory.newInstance().createFault("custom fault from client", SOAPConstants.SOAP_SENDER_FAULT);
    WSEndpointReference to = new WSEndpointReference(getAddress(), AddressingVersion.MEMBER);
    OneWayFeature owf = new OneWayFeature();
    owf.setRelatesToID("uuid:foobar");
    WSService service = WSService.create();
    service.addPort(PORT_QNAME, SOAPBinding.SOAP11HTTP_BINDING, getAddress());
    Dispatch<Source> dispatch = service.createDispatch(PORT_QNAME, to, Source.class, Service.Mode.PAYLOAD, new MemberSubmissionAddressingFeature(true), owf);
    // Since this fault is not a wsdl operation, we need to set SOAPAction for correct wsa:Action
    dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
    dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "http://example.com/myfault");
    try {
        dispatch.invokeOneWay(new DOMSource(fault));
    } catch (WebServiceException e) {
    // since the server-side is not provider based for this test.
    // it does n't know from the fault message request that it is oneway and throws 500 code.
    // so, expect a WebServcieException here.
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) OneWayFeature(com.sun.xml.ws.api.addressing.OneWayFeature) WSService(com.sun.xml.ws.api.WSService) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) SOAPFault(jakarta.xml.soap.SOAPFault) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source)

Aggregations

WSService (com.sun.xml.ws.api.WSService)4 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)3 WSBinding (com.sun.xml.ws.api.WSBinding)2 ClientTubeAssemblerContext (com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)2 Component (com.sun.xml.ws.api.Component)1 EndpointAddress (com.sun.xml.ws.api.EndpointAddress)1 OneWayFeature (com.sun.xml.ws.api.addressing.OneWayFeature)1 WSPortInfo (com.sun.xml.ws.api.client.WSPortInfo)1 Header (com.sun.xml.ws.api.message.Header)1 Packet (com.sun.xml.ws.api.message.Packet)1 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)1 WSDLService (com.sun.xml.ws.api.model.wsdl.WSDLService)1 Fiber (com.sun.xml.ws.api.pipe.Fiber)1 Tube (com.sun.xml.ws.api.pipe.Tube)1 BindingImpl (com.sun.xml.ws.binding.BindingImpl)1 WSServiceDelegate (com.sun.xml.ws.client.WSServiceDelegate)1 MemberSubmissionAddressingFeature (com.sun.xml.ws.developer.MemberSubmissionAddressingFeature)1 WSBindingProvider (com.sun.xml.ws.developer.WSBindingProvider)1 SOAPFault (jakarta.xml.soap.SOAPFault)1 EndpointReference (jakarta.xml.ws.EndpointReference)1