Search in sources :

Example 21 with W3CEndpointReference

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

the class EndpointReferenceUtil method toW3CEpr.

// TODO: bit of redundency on writes of w3c epr, should modularize it
private static W3CEndpointReference toW3CEpr(MemberSubmissionEndpointReference msEpr) {
    StreamWriterBufferCreator writer = new StreamWriterBufferCreator();
    w3cMetadataWritten = false;
    try {
        writer.writeStartDocument();
        writer.writeStartElement(AddressingVersion.W3C.getPrefix(), "EndpointReference", AddressingVersion.W3C.nsUri);
        writer.writeNamespace(AddressingVersion.W3C.getPrefix(), AddressingVersion.W3C.nsUri);
        // write wsa:Address
        writer.writeStartElement(AddressingVersion.W3C.getPrefix(), AddressingVersion.W3C.eprType.address, AddressingVersion.W3C.nsUri);
        writer.writeCharacters(msEpr.addr.uri);
        writer.writeEndElement();
        // TODO: write extension attributes on wsa:Address
        if ((msEpr.referenceProperties != null && msEpr.referenceProperties.elements.size() > 0) || (msEpr.referenceParameters != null && msEpr.referenceParameters.elements.size() > 0)) {
            writer.writeStartElement(AddressingVersion.W3C.getPrefix(), "ReferenceParameters", AddressingVersion.W3C.nsUri);
            // write ReferenceProperties
            if (msEpr.referenceProperties != null) {
                for (Element e : msEpr.referenceProperties.elements) {
                    DOMUtil.serializeNode(e, writer);
                }
            }
            // write referenceParameters
            if (msEpr.referenceParameters != null) {
                for (Element e : msEpr.referenceParameters.elements) {
                    DOMUtil.serializeNode(e, writer);
                }
            }
            writer.writeEndElement();
        }
        // Supress writing ServiceName and EndpointName in W3CEPR,
        // Until the ns for those metadata elements is resolved.
        /*
            //Write Interface info
            if (msEpr.portTypeName != null) {
                writeW3CMetadata(writer);
                writer.writeStartElement(AddressingVersion.W3C.getWsdlPrefix(),
                        AddressingVersion.W3C.eprType.portTypeName ,
                        AddressingVersion.W3C.wsdlNsUri);
                writer.writeNamespace(AddressingVersion.W3C.getWsdlPrefix(),
                        AddressingVersion.W3C.wsdlNsUri);
                String portTypePrefix = fixNull(msEpr.portTypeName.name.getPrefix());
                writer.writeNamespace(portTypePrefix, msEpr.portTypeName.name.getNamespaceURI());
                if (portTypePrefix.equals(""))
                    writer.writeCharacters(msEpr.portTypeName.name.getLocalPart());
                else
                    writer.writeCharacters(portTypePrefix + ":" + msEpr.portTypeName.name.getLocalPart());
                writer.writeEndElement();
            }
            if (msEpr.serviceName != null) {
                writeW3CMetadata(writer);
                //Write service and Port info
                writer.writeStartElement(AddressingVersion.W3C.getWsdlPrefix(),
                        AddressingVersion.W3C.eprType.serviceName ,
                        AddressingVersion.W3C.wsdlNsUri);
                writer.writeNamespace(AddressingVersion.W3C.getWsdlPrefix(),
                        AddressingVersion.W3C.wsdlNsUri);

                String servicePrefix = fixNull(msEpr.serviceName.name.getPrefix());
                if (msEpr.serviceName.portName != null)
                    writer.writeAttribute(AddressingVersion.W3C.eprType.portName,
                            msEpr.serviceName.portName);

                writer.writeNamespace(servicePrefix, msEpr.serviceName.name.getNamespaceURI());
                if (servicePrefix.length() > 0)
                    writer.writeCharacters(servicePrefix + ":" + msEpr.serviceName.name.getLocalPart());
                else
                    writer.writeCharacters(msEpr.serviceName.name.getLocalPart());
                writer.writeEndElement();
            }
            */
        // TODO: revisit this
        Element wsdlElement = null;
        // Check for wsdl in extension elements
        if ((msEpr.elements != null) && (msEpr.elements.size() > 0)) {
            for (Element e : msEpr.elements) {
                if (e.getNamespaceURI().equals(MemberSubmissionAddressingConstants.MEX_METADATA.getNamespaceURI()) && e.getLocalName().equals(MemberSubmissionAddressingConstants.MEX_METADATA.getLocalPart())) {
                    NodeList nl = e.getElementsByTagNameNS(WSDLConstants.NS_WSDL, WSDLConstants.QNAME_DEFINITIONS.getLocalPart());
                    if (nl != null) {
                        wsdlElement = (Element) nl.item(0);
                    }
                }
            }
        }
        // write WSDL
        if (wsdlElement != null) {
            DOMUtil.serializeNode(wsdlElement, writer);
        }
        if (w3cMetadataWritten) {
            writer.writeEndElement();
        }
        // write extension elements
        if ((msEpr.elements != null) && (msEpr.elements.size() > 0)) {
            for (Element e : msEpr.elements) {
                if (e.getNamespaceURI().equals(WSDLConstants.NS_WSDL) && e.getLocalName().equals(WSDLConstants.QNAME_DEFINITIONS.getLocalPart())) {
                // Don't write it as this is written already in Metadata
                }
                DOMUtil.serializeNode(e, writer);
            }
        }
        // TODO:write extension attributes
        // </EndpointReference>
        writer.writeEndElement();
        writer.writeEndDocument();
        writer.flush();
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
    return new W3CEndpointReference(new XMLStreamBufferSource(writer.getXMLStreamBuffer()));
}
Also used : XMLStreamBufferSource(com.sun.xml.stream.buffer.XMLStreamBufferSource) XMLStreamException(javax.xml.stream.XMLStreamException) WebServiceException(jakarta.xml.ws.WebServiceException) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) StreamWriterBufferCreator(com.sun.xml.stream.buffer.stax.StreamWriterBufferCreator)

Example 22 with W3CEndpointReference

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

the class WSEndpointReferenceTest method testCreateViaSpec.

public void testCreateViaSpec() throws Exception {
    W3CEndpointReference spec = new W3CEndpointReference(new StreamSource(getClass().getResource("test-epr.xml").toExternalForm()));
    new WSEndpointReference(spec, W3C);
}
Also used : W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) StreamSource(javax.xml.transform.stream.StreamSource) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference)

Example 23 with W3CEndpointReference

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

the class EndpointEPRTester method testProviderEndpointW3CEPR.

public void testProviderEndpointW3CEPR() {
    int port = Util.getFreePort();
    String address = "http://127.0.0.1:" + port + "/";
    Endpoint e = Endpoint.create(HTTPBinding.HTTP_BINDING, new MyProvider());
    e.publish(address);
    W3CEndpointReference epr = e.getEndpointReference(W3CEndpointReference.class);
    e.stop();
    printEPR(epr);
    EprUtil.validateEPR(epr, address, null, null, null, Boolean.FALSE);
}
Also used : Endpoint(jakarta.xml.ws.Endpoint) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) Endpoint(jakarta.xml.ws.Endpoint)

Example 24 with W3CEndpointReference

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

the class ClientEpr method msEprGettertest.

private void msEprGettertest(BindingProvider bp, boolean hasWSDL) throws Exception {
    Service service = Service.create(serviceName);
    service.addPort(portName, jakarta.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
    Dispatch dispatch = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
    // validate ms epr
    MemberSubmissionEndpointReference msEpr = bp.getEndpointReference(MemberSubmissionEndpointReference.class);
    // printEPR(msEpr);
    assertTrue(EprUtil.validateEPR(msEpr, endpointAddress, serviceName, portName, portTypeName, hasWSDL));
    W3CEndpointReference w3cEpr = bp.getEndpointReference(W3CEndpointReference.class);
    // printEPR(w3cEpr);
    // assertTrue(EprUtil.validateEPR(w3cEpr,endpointAddress, serviceName, portName, portTypeName, hasWSDL));
    assertTrue(EprUtil.validateEPR(w3cEpr, endpointAddress, null, null, null, false));
}
Also used : W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) Service(jakarta.xml.ws.Service) Dispatch(jakarta.xml.ws.Dispatch) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Example 25 with W3CEndpointReference

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

the class ClientEpr method w3cEprGettertest.

private void w3cEprGettertest(BindingProvider bp, boolean hasWSDL) throws Exception {
    // validate w3c epr
    W3CEndpointReference w3cEpr = (W3CEndpointReference) bp.getEndpointReference();
    // printEPR(w3cEpr);
    // assertTrue(EprUtil.validateEPR(w3cEpr,endpointAddress, serviceName, portName, portTypeName, hasWSDL));
    assertTrue(EprUtil.validateEPR(w3cEpr, endpointAddress, null, null, null, false));
    // validate ms epr
    MemberSubmissionEndpointReference msEpr = bp.getEndpointReference(MemberSubmissionEndpointReference.class);
    // printEPR(msEpr);
    assertTrue(EprUtil.validateEPR(msEpr, endpointAddress, serviceName, portName, portTypeName, hasWSDL));
}
Also used : W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Aggregations

W3CEndpointReference (jakarta.xml.ws.wsaddressing.W3CEndpointReference)44 MemberSubmissionEndpointReference (com.sun.xml.ws.developer.MemberSubmissionEndpointReference)19 W3CEndpointReferenceBuilder (jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)10 StreamResult (javax.xml.transform.stream.StreamResult)9 StreamSource (javax.xml.transform.stream.StreamSource)9 Endpoint (jakarta.xml.ws.Endpoint)6 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 QName (javax.xml.namespace.QName)5 Source (javax.xml.transform.Source)5 DOMResult (javax.xml.transform.dom.DOMResult)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 URL (java.net.URL)4 ArrayList (java.util.ArrayList)4 Node (org.w3c.dom.Node)3 JAXBContext (jakarta.xml.bind.JAXBContext)2 JAXBException (jakarta.xml.bind.JAXBException)2 Marshaller (jakarta.xml.bind.Marshaller)2 JAXBResult (jakarta.xml.bind.util.JAXBResult)2 BindingProvider (jakarta.xml.ws.BindingProvider)2