Search in sources :

Example 1 with WSEPRExtension

use of com.sun.xml.ws.addressing.WSEPRExtension 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 2 with WSEPRExtension

use of com.sun.xml.ws.addressing.WSEPRExtension in project metro-jax-ws by eclipse-ee4j.

the class WSEndpointReference method parseEPRExtensions.

private void parseEPRExtensions() throws XMLStreamException {
    rootEprExtensions = new HashMap<>();
    StreamReaderBufferProcessor xsr = infoset.readAsXMLStreamReader();
    // parser should be either at the start element or the start document
    if (xsr.getEventType() == XMLStreamReader.START_DOCUMENT) {
        xsr.nextTag();
    }
    assert xsr.getEventType() == XMLStreamReader.START_ELEMENT;
    if (!xsr.getNamespaceURI().equals(version.nsUri)) {
        throw new WebServiceException(AddressingMessages.WRONG_ADDRESSING_VERSION(version.nsUri, xsr.getNamespaceURI()));
    }
    // since often EPR doesn't have extensions, create array lazily
    XMLStreamBuffer mark;
    String localName;
    String ns;
    while ((mark = xsr.nextTagAndMark()) != null) {
        localName = xsr.getLocalName();
        ns = xsr.getNamespaceURI();
        if (version.nsUri.equals(ns)) {
            // EPR extensions do not use the same namespace of the Addressing Version.
            // Not an extension -  SKIP
            XMLStreamReaderUtil.skipElement(xsr);
        } else {
            QName qn = new QName(ns, localName);
            rootEprExtensions.put(qn, new WSEPRExtension(mark, qn));
            XMLStreamReaderUtil.skipElement(xsr);
        }
    }
// hit to </EndpointReference> by now
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) MutableXMLStreamBuffer(com.sun.xml.stream.buffer.MutableXMLStreamBuffer) XMLStreamBuffer(com.sun.xml.stream.buffer.XMLStreamBuffer) StreamReaderBufferProcessor(com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor) WSEPRExtension(com.sun.xml.ws.addressing.WSEPRExtension)

Aggregations

WSEPRExtension (com.sun.xml.ws.addressing.WSEPRExtension)2 WebServiceException (jakarta.xml.ws.WebServiceException)2 QName (javax.xml.namespace.QName)2 MutableXMLStreamBuffer (com.sun.xml.stream.buffer.MutableXMLStreamBuffer)1 XMLStreamBuffer (com.sun.xml.stream.buffer.XMLStreamBuffer)1 StreamReaderBufferProcessor (com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor)1 AddressingVersion (com.sun.xml.ws.api.addressing.AddressingVersion)1 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)1 ArrayList (java.util.ArrayList)1 XMLStreamException (javax.xml.stream.XMLStreamException)1