Search in sources :

Example 1 with EndpointAddress

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

the class RewritingMOM method createManagedObjectManager.

/**
 * Client monitoring is OFF by default because there is
 * no standard stub.close() method.  Therefore people do
 * not typically close a stub when they are done with it
 * (even though the RI does provide a .close).
 * <pre>
 * prop    |  no assert | assert/no mon | assert/mon off | assert/mon on
 * -------------------------------------------------------------------
 * not set |    off     |      off      |     off        |     on
 * false   |    off     |      off      |     off        |     off
 * true    |    on      |      on       |     off        |     on
 * </pre>
 */
@NotNull
public ManagedObjectManager createManagedObjectManager(final Stub stub) {
    EndpointAddress ea = stub.requestContext.getEndpointAddress();
    if (ea == null) {
        return ManagedObjectManagerFactory.createNOOP();
    }
    String rootName = ea.toString();
    final ManagedClientAssertion assertion = ManagedClientAssertion.getAssertion(stub.getPortInfo());
    if (assertion != null) {
        final String id = assertion.getId();
        if (id != null) {
            rootName = id;
        }
        if (assertion.monitoringAttribute() == Setting.OFF) {
            return disabled("This client", rootName);
        } else if (assertion.monitoringAttribute() == Setting.ON && clientMonitoring != Setting.OFF) {
            return createMOMLoop(rootName, 0);
        }
    }
    if (clientMonitoring == Setting.NOT_SET || clientMonitoring == Setting.OFF) {
        return disabled("Global client", rootName);
    }
    return createMOMLoop(rootName, 0);
}
Also used : ManagedClientAssertion(com.sun.xml.ws.api.config.management.policy.ManagedClientAssertion) EndpointAddress(com.sun.xml.ws.api.EndpointAddress) NotNull(com.sun.istack.NotNull)

Example 2 with EndpointAddress

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

the class WsaServerTube method processResponse.

@Override
@NotNull
public NextAction processResponse(Packet response) {
    Message msg = response.getMessage();
    if (msg == null) {
        return doReturnWith(response);
    }
    // one way message. Nothing to see here. Move on.
    String to = AddressingUtils.getTo(msg.getHeaders(), addressingVersion, soapVersion);
    if (to != null) {
        replyTo = faultTo = new WSEndpointReference(to, addressingVersion);
    }
    if (replyTo == null) {
        // This is an async response or we're not processing the response in
        // the same tube instance as we processed the request. Get the ReplyTo
        // now, from the properties we stored into the request packet. We
        // assume anyone that interrupted the request->response flow will have
        // saved the ReplyTo and put it back into the packet for our use.
        replyTo = (WSEndpointReference) response.get(WsaPropertyBag.WSA_REPLYTO_FROM_REQUEST);
    }
    if (faultTo == null) {
        // This is an async response or we're not processing the response in
        // the same tube instance as we processed the request. Get the FaultTo
        // now, from the properties we stored into the request packet. We
        // assume anyone that interrupted the request->response flow will have
        // saved the FaultTo and put it back into the packet for our use.
        faultTo = (WSEndpointReference) response.get(WsaPropertyBag.WSA_FAULTTO_FROM_REQUEST);
    }
    WSEndpointReference target = msg.isFault() ? faultTo : replyTo;
    if (target == null && response.proxy instanceof Stub) {
        target = ((Stub) response.proxy).getWSEndpointReference();
    }
    if (target == null || target.isAnonymous() || isAnonymousRequired) {
        return doReturnWith(response);
    }
    if (target.isNone()) {
        // the caller doesn't want to hear about it, so proceed like one-way
        response.setMessage(null);
        return doReturnWith(response);
    }
    if ((wsdlPort != null) && response.getMessage().isOneWay(wsdlPort)) {
        // one way message but with replyTo. I believe this is a hack for WS-TX - KK.
        LOGGER.fine(AddressingMessages.NON_ANONYMOUS_RESPONSE_ONEWAY());
        return doReturnWith(response);
    }
    // action value.
    if (wbo != null || response.soapAction == null) {
        String action = response.getMessage().isFault() ? helper.getFaultAction(wbo, response) : helper.getOutputAction(wbo);
        // set the SOAPAction, as its got to be same as wsa:Action
        if (response.soapAction == null || (action != null && !action.equals(AddressingVersion.UNSET_OUTPUT_ACTION))) {
            response.soapAction = action;
        }
    }
    response.expectReply = false;
    EndpointAddress adrs;
    try {
        adrs = new EndpointAddress(URI.create(target.getAddress()));
    } catch (NullPointerException | IllegalArgumentException e) {
        throw new WebServiceException(e);
    }
    response.endpointAddress = adrs;
    if (response.isAdapterDeliversNonAnonymousResponse) {
        return doReturnWith(response);
    }
    return doReturnWith(NonAnonymousResponseProcessor.getDefault().process(response));
}
Also used : Message(com.sun.xml.ws.api.message.Message) WebServiceException(jakarta.xml.ws.WebServiceException) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) Stub(com.sun.xml.ws.client.Stub) EndpointAddress(com.sun.xml.ws.api.EndpointAddress) NotNull(com.sun.istack.NotNull)

Example 3 with EndpointAddress

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

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

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

the class RuntimeWSDLParser method parsePort.

private void parsePort(XMLStreamReader reader, EditableWSDLService service) {
    port_nsdecl.putAll(service_nsdecl);
    readNSDecl(port_nsdecl, reader);
    String portName = ParserUtil.getMandatoryNonEmptyAttribute(reader, WSDLConstants.ATTR_NAME);
    String binding = ParserUtil.getMandatoryNonEmptyAttribute(reader, "binding");
    QName bindingName = ParserUtil.getQName(reader, binding);
    QName portQName = new QName(service.getName().getNamespaceURI(), portName);
    EditableWSDLPort port = new WSDLPortImpl(reader, service, portQName, bindingName);
    extensionFacade.portAttributes(port, reader);
    String location;
    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
        QName name = reader.getName();
        if (SOAPConstants.QNAME_ADDRESS.equals(name) || SOAPConstants.QNAME_SOAP12ADDRESS.equals(name)) {
            location = ParserUtil.getMandatoryNonEmptyAttribute(reader, WSDLConstants.ATTR_LOCATION);
            if (location != null) {
                try {
                    port.setAddress(new EndpointAddress(location));
                } catch (URISyntaxException e) {
                // Lets not throw any exception, latter on it should be thrown when invocation happens. At this
                // time user has option to set the endopint address using request contexxt property.
                }
            }
            XMLStreamReaderUtil.next(reader);
        } else if (AddressingVersion.W3C.nsUri.equals(name.getNamespaceURI()) && "EndpointReference".equals(name.getLocalPart())) {
            try {
                StreamReaderBufferCreator creator = new StreamReaderBufferCreator(new MutableXMLStreamBuffer());
                XMLStreamBuffer eprbuffer = new XMLStreamBufferMark(port_nsdecl, creator);
                creator.createElementFragment(reader, false);
                WSEndpointReference wsepr = new WSEndpointReference(eprbuffer, AddressingVersion.W3C);
                // wsepr.toSpec().writeTo(new StreamResult(System.out));
                port.setEPR(wsepr);
                /* XMLStreamBuffer.createNewBufferFromXMLStreamReader(reader) called from inside WSEndpointReference()
                       consumes the complete EPR infoset and moves to the next element. This breaks the normal wsdl parser
                       processing where it expects anyone reading the infoset to move to the end of the element that its reading
                       and not to the next element.
                     */
                if (reader.getEventType() == XMLStreamConstants.END_ELEMENT && reader.getName().equals(WSDLConstants.QNAME_PORT))
                    break;
            } catch (XMLStreamException e) {
                throw new WebServiceException(e);
            }
        } else {
            extensionFacade.portElements(port, reader);
        }
    }
    if (port.getAddress() == null) {
        try {
            port.setAddress(new EndpointAddress(""));
        } catch (URISyntaxException e) {
        // Lets not throw any exception, latter on it should be thrown when invocation happens. At this
        // time user has option to set the endopint address using request contexxt property.
        }
    }
    service.put(portQName, port);
    port_nsdecl = new HashMap<>();
}
Also used : StreamReaderBufferCreator(com.sun.xml.stream.buffer.stax.StreamReaderBufferCreator) WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) URISyntaxException(java.net.URISyntaxException) XMLStreamBufferMark(com.sun.xml.stream.buffer.XMLStreamBufferMark) MutableXMLStreamBuffer(com.sun.xml.stream.buffer.MutableXMLStreamBuffer) EditableWSDLPort(com.sun.xml.ws.api.model.wsdl.editable.EditableWSDLPort) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) MutableXMLStreamBuffer(com.sun.xml.stream.buffer.MutableXMLStreamBuffer) XMLStreamBuffer(com.sun.xml.stream.buffer.XMLStreamBuffer) EndpointAddress(com.sun.xml.ws.api.EndpointAddress)

Aggregations

EndpointAddress (com.sun.xml.ws.api.EndpointAddress)5 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)4 QName (javax.xml.namespace.QName)3 NotNull (com.sun.istack.NotNull)2 Component (com.sun.xml.ws.api.Component)2 WSBinding (com.sun.xml.ws.api.WSBinding)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 ClientTubeAssemblerContext (com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)2 WSServiceDelegate (com.sun.xml.ws.client.WSServiceDelegate)2 WSBindingProvider (com.sun.xml.ws.developer.WSBindingProvider)2 EndpointReference (jakarta.xml.ws.EndpointReference)2 WebServiceException (jakarta.xml.ws.WebServiceException)2 List (java.util.List)2 MutableXMLStreamBuffer (com.sun.xml.stream.buffer.MutableXMLStreamBuffer)1 XMLStreamBuffer (com.sun.xml.stream.buffer.XMLStreamBuffer)1 XMLStreamBufferMark (com.sun.xml.stream.buffer.XMLStreamBufferMark)1 StreamReaderBufferCreator (com.sun.xml.stream.buffer.stax.StreamReaderBufferCreator)1 BindingID (com.sun.xml.ws.api.BindingID)1