Search in sources :

Example 41 with W3CEndpointReference

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

the class EPRTest method test.

public void test() {
    Test proxy = new TestService().getTestPort();
    W3CEndpointReferenceBuilder eprbuilder = new W3CEndpointReferenceBuilder();
    String address = "http://example.com";
    eprbuilder.address(address);
    W3CEndpointReference epr = eprbuilder.build();
    W3CEndpointReference ret = proxy.test(epr);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ret.writeTo(new StreamResult(baos));
    String retEprStr = new String(baos.toByteArray());
    assertTrue(retEprStr.contains(address));
}
Also used : W3CEndpointReferenceBuilder(jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) StreamResult(javax.xml.transform.stream.StreamResult) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 42 with W3CEndpointReference

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

the class W3CEPRTest method testEPRWithReferenceParameters.

public void testEPRWithReferenceParameters() throws Exception {
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    builder = builder.address(getEndpointAddress());
    DOMSource domsrc = makeDOMSource(xmlInterfaceName);
    Document document = (Document) domsrc.getNode();
    builder = builder.metadata(document.getDocumentElement());
    builder = builder.serviceName(SERVICE_QNAME);
    builder = builder.endpointName(PORT_QNAME);
    // builder = builder.wsdlDocumentLocation(wsdlurl.toString());
    domsrc = makeDOMSource(xmlRefParam1);
    document = (Document) domsrc.getNode();
    builder = builder.referenceParameter(document.getDocumentElement());
    domsrc = makeDOMSource(xmlRefParam2);
    document = (Document) domsrc.getNode();
    builder = builder.referenceParameter(document.getDocumentElement());
    W3CEndpointReference epr = builder.build();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    epr.writeTo(new StreamResult(baos));
    AddNumbersService service = new AddNumbersService();
    AddNumbersPortType myport = (AddNumbersPortType) service.getPort(epr, AddNumbersPortType.class, new AddressingFeature(true, true));
    myport.addNumbers(10, 10);
}
Also used : W3CEndpointReferenceBuilder(jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) DOMSource(javax.xml.transform.dom.DOMSource) AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) StreamResult(javax.xml.transform.stream.StreamResult) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Document(org.w3c.dom.Document)

Example 43 with W3CEndpointReference

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

the class HelloLiteralTest method testEchoArray.

// Tests epr overriding
// epr(1 reference parameter) passed as argument overrides epr in wsdl(2 reference parameters)
public void testEchoArray() 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 endpointAddress = (String) ((BindingProvider) stub).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
        W3CEndpointReferenceBuilder eprBuilder = new W3CEndpointReferenceBuilder();
        eprBuilder.address(endpointAddress);
        eprBuilder.referenceParameter((Element) n1.getFirstChild());
        W3CEndpointReference epr = eprBuilder.build();
        Hello_Service service = new Hello_Service();
        Hello newStub = service.getPort(epr, Hello.class);
        String[] in = { "JAXRPC 1.0", "JAXRPC 1.1", "JAXRPC 1.1.2", "JAXRPC 2.0" };
        NameType nt = new NameType();
        nt.getName().add(in[0]);
        nt.getName().add(in[1]);
        nt.getName().add(in[2]);
        nt.getName().add(in[3]);
        jakarta.xml.ws.Holder<NameType> req = new jakarta.xml.ws.Holder<NameType>(nt);
        newStub.echoArray(req);
        assertTrue(req.value == null);
    } catch (Exception e) {
        e.printStackTrace();
        assertTrue(false);
    }
}
Also used : Node(org.w3c.dom.Node) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) W3CEndpointReferenceBuilder(jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) jakarta.xml.ws(jakarta.xml.ws)

Example 44 with W3CEndpointReference

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

the class EndpointEPRTest method testW3CEPR.

public void testW3CEPR() throws Exception {
    int port = PortAllocator.getFreePort();
    String address = "http://localhost:" + port + "/hello";
    Endpoint endpoint = Endpoint.create(new RpcLitEndpoint());
    List<Source> metadata = new ArrayList<Source>();
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    String[] docs = { "RpcLitEndpoint.wsdl", "RpcLitAbstract.wsdl", "RpcLitEndpoint.xsd" };
    for (String doc : docs) {
        URL url = cl.getResource(doc);
        metadata.add(new StreamSource(url.openStream(), url.toExternalForm()));
    }
    endpoint.setMetadata(metadata);
    endpoint.publish(address);
    W3CEndpointReference epr = endpoint.getEndpointReference(W3CEndpointReference.class);
    endpoint.stop();
    EprUtil.validateEPR(epr, address, null, /*serviceName*/
    null, /*portName*/
    null, /*portTypeName*/
    Boolean.FALSE);
    printEPR(epr);
}
Also used : Endpoint(jakarta.xml.ws.Endpoint) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) StreamSource(javax.xml.transform.stream.StreamSource) ArrayList(java.util.ArrayList) Endpoint(jakarta.xml.ws.Endpoint) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) URL(java.net.URL)

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