Search in sources :

Example 6 with W3CEndpointReferenceBuilder

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

the class W3CEPRTest method testW3CEprBuilder_withWSDL.

public void testW3CEprBuilder_withWSDL() throws Exception {
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    builder = builder.address(getEndpointAddress());
    builder = builder.wsdlDocumentLocation(getEndpointAddress() + "?wsdl");
    W3CEndpointReference epr = builder.build();
    DOMResult result = new DOMResult();
    epr.writeTo(result);
    assertTrue(EprUtil.validateEPR(result.getNode(), W3CEndpointReference.class, getEndpointAddress(), null, null, null, null));
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// epr.writeTo(new StreamResult(baos));
// baos.writeTo(System.out);
}
Also used : W3CEndpointReferenceBuilder(jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) DOMResult(javax.xml.transform.dom.DOMResult) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference)

Example 7 with W3CEndpointReferenceBuilder

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

the class EprMarshalUnmarshalTester method testW3CEprMarshalling.

public void testW3CEprMarshalling() throws Exception {
    JAXBContext ctx = JAXBContext.newInstance(W3CEndpointReference.class);
    JAXBResult res = new JAXBResult(ctx);
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    builder.address("http://example.com");
    W3CEndpointReference epr = builder.build();
    // You will get the NPE
    epr.writeTo(res);
}
Also used : W3CEndpointReferenceBuilder(jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) JAXBContext(jakarta.xml.bind.JAXBContext) JAXBResult(jakarta.xml.bind.util.JAXBResult)

Example 8 with W3CEndpointReferenceBuilder

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

the class ReferenceParametersTest method testReferenceParametersConversion2.

public void testReferenceParametersConversion2() throws Exception {
    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    docFactory.setNamespaceAware(true);
    DocumentBuilder db = docFactory.newDocumentBuilder();
    Document doc = db.newDocument();
    Element el1 = doc.createElementNS("http:foo.bar", "Element1");
    Element el2 = doc.createElementNS("http:foo.bar", "Element1");
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    EndpointReference epr = builder.address("http://foo.bar").referenceParameter(el1).referenceParameter(el2).build();
    System.out.println("EPR " + epr);
    WSEndpointReference wsepr = new WSEndpointReference(epr);
    MemberSubmissionEndpointReference translated = wsepr.toSpec(MemberSubmissionEndpointReference.class);
    assert (translated.referenceParameters.elements.size() == 2);
}
Also used : W3CEndpointReferenceBuilder(jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) Document(org.w3c.dom.Document) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference) EndpointReference(jakarta.xml.ws.EndpointReference)

Example 9 with W3CEndpointReferenceBuilder

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

the class ReferenceParametersTest method testReferenceParametersConversion3.

public void testReferenceParametersConversion3() throws Exception {
    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    docFactory.setNamespaceAware(true);
    DocumentBuilder db = docFactory.newDocumentBuilder();
    Document doc = db.newDocument();
    Element el1 = doc.createElementNS("http:foo.bar", "Element1");
    Element el2 = doc.createElementNS("http:foo.bar", "Element1");
    Element el3 = doc.createElementNS("http:foo.bar", "Element1");
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    EndpointReference epr = builder.address("http://foo.bar").referenceParameter(el1).referenceParameter(el2).referenceParameter(el3).build();
    System.out.println("EPR " + epr);
    WSEndpointReference wsepr = new WSEndpointReference(epr);
    MemberSubmissionEndpointReference translated = wsepr.toSpec(MemberSubmissionEndpointReference.class);
    assert (translated.referenceParameters.elements.size() == 3);
}
Also used : W3CEndpointReferenceBuilder(jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) Document(org.w3c.dom.Document) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference) EndpointReference(jakarta.xml.ws.EndpointReference)

Example 10 with W3CEndpointReferenceBuilder

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

the class EprMarshalUnmarshalTester method testW3CEPRBuilder.

public void testW3CEPRBuilder() throws Exception {
    try {
        String xmlParam1 = "<myns:MyParam1 xmlns:myns=\"http://cptestservice.org/wsdl\">Hello</myns:MyParam1>";
        Node n1 = DOMUtil.createDOMNode(new ByteArrayInputStream(xmlParam1.getBytes()));
        String metadata = "<myMetadata>This is not useful metadata</myMetadata>";
        Node n2 = createDOMNodeNoNS(new ByteArrayInputStream(metadata.getBytes()));
        W3CEndpointReferenceBuilder eprBuilder = new W3CEndpointReferenceBuilder();
        eprBuilder.address(endpointAddress);
        eprBuilder.referenceParameter((Element) n1.getFirstChild());
        eprBuilder.metadata((Element) n2.getFirstChild());
        W3CEndpointReference epr = eprBuilder.build();
        epr.writeTo(new StreamResult(System.out));
    } catch (Exception e) {
        e.printStackTrace();
        assertTrue(false);
    }
}
Also used : W3CEndpointReferenceBuilder(jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) StreamResult(javax.xml.transform.stream.StreamResult) ByteArrayInputStream(java.io.ByteArrayInputStream) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) Node(org.w3c.dom.Node) IOException(java.io.IOException) JAXBException(jakarta.xml.bind.JAXBException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Aggregations

W3CEndpointReferenceBuilder (jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)16 W3CEndpointReference (jakarta.xml.ws.wsaddressing.W3CEndpointReference)10 Document (org.w3c.dom.Document)8 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)6 MemberSubmissionEndpointReference (com.sun.xml.ws.developer.MemberSubmissionEndpointReference)6 EndpointReference (jakarta.xml.ws.EndpointReference)6 DocumentBuilder (javax.xml.parsers.DocumentBuilder)6 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)6 Element (org.w3c.dom.Element)6 StreamResult (javax.xml.transform.stream.StreamResult)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 DOMResult (javax.xml.transform.dom.DOMResult)3 Node (org.w3c.dom.Node)3 JAXBContext (jakarta.xml.bind.JAXBContext)2 JAXBException (jakarta.xml.bind.JAXBException)2 JAXBResult (jakarta.xml.bind.util.JAXBResult)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 DOMSource (javax.xml.transform.dom.DOMSource)2