Search in sources :

Example 6 with EndpointReference

use of javax.xml.ws.EndpointReference in project cxf by apache.

the class Client method main.

public static void main(String[] args) throws Exception {
    // Use WS-Discovery to find references to services that implement the Greeter portType
    WSDiscoveryClient client = new WSDiscoveryClient();
    List<EndpointReference> references = client.probe(new QName("http://cxf.apache.org/hello_world/discovery", "Greeter"));
    client.close();
    GreeterService service = new GreeterService();
    // loop through all of them and have them greet me.
    for (EndpointReference ref : references) {
        Greeter g = service.getPort(ref, Greeter.class);
        System.out.println(g.greetMe("World"));
    }
}
Also used : QName(javax.xml.namespace.QName) Greeter(org.apache.cxf.hello_world.discovery.Greeter) WSDiscoveryClient(org.apache.cxf.ws.discovery.WSDiscoveryClient) GreeterService(org.apache.cxf.hello_world.discovery.GreeterService) EndpointReference(javax.xml.ws.EndpointReference)

Example 7 with EndpointReference

use of javax.xml.ws.EndpointReference in project cxf by apache.

the class CallbackClientServerTest method testCallback.

@Test
public void testCallback() throws Exception {
    Object implementor = new CallbackImpl();
    String address = "http://localhost:" + CB_PORT + "/CallbackContext/CallbackPort";
    Endpoint ep = Endpoint.publish(address, implementor);
    URL wsdlURL = getClass().getResource("/wsdl/basic_callback_test.wsdl");
    SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
    ServerPortType port = ss.getPort(PORT_NAME, ServerPortType.class);
    updateAddressPort(port, PORT);
    EndpointReference w3cEpr = ep.getEndpointReference();
    String resp = port.registerCallback((W3CEndpointReference) w3cEpr);
    assertEquals("registerCallback called", resp);
    ep.stop();
}
Also used : SOAPService(org.apache.callback.SOAPService) Endpoint(javax.xml.ws.Endpoint) ServerPortType(org.apache.callback.ServerPortType) URL(java.net.URL) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Test(org.junit.Test)

Example 8 with EndpointReference

use of javax.xml.ws.EndpointReference in project cxf by apache.

the class EndpointReferenceTest method testEndpointGetEndpointReferenceSOAPBinding.

@Test
public void testEndpointGetEndpointReferenceSOAPBinding() throws Exception {
    GreeterImpl greeter = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String) null)) {
        endpoint.publish("http://localhost:8080/test");
        InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
        Document doc = StaxUtils.read(is);
        Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(), "wsa:ReferenceParameters", "");
        EndpointReference endpointReference = endpoint.getEndpointReference(referenceParameters);
        assertNotNull(endpointReference);
        assertTrue(endpointReference instanceof W3CEndpointReference);
        // A returned W3CEndpointReferenceMUST also contain the specified referenceParameters.
        // W3CEndpointReference wer = (W3CEndpointReference)endpointReference;
        endpoint.stop();
    }
}
Also used : InputStream(java.io.InputStream) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Element(org.w3c.dom.Element) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) Document(org.w3c.dom.Document) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Test(org.junit.Test)

Example 9 with EndpointReference

use of javax.xml.ws.EndpointReference in project cxf by apache.

the class EndpointReferenceTest method testProviderGetPort.

@Test
public void testProviderGetPort() throws Exception {
    BusFactory.setDefaultBus(getBus());
    GreeterImpl greeter1 = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String) null)) {
        endpoint.publish("http://localhost:8080/test");
        ProviderImpl provider = new ProviderImpl();
        InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
        Document doc = StaxUtils.read(is);
        DOMSource erXML = new DOMSource(doc);
        EndpointReference endpointReference = EndpointReference.readFrom(erXML);
        WebServiceFeature[] wfs = new WebServiceFeature[] {};
        Greeter greeter = provider.getPort(endpointReference, Greeter.class, wfs);
        String response = greeter.greetMe("John");
        assertEquals("Hello John", response);
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) InputStream(java.io.InputStream) Greeter(org.apache.hello_world_soap_http.Greeter) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) WebServiceFeature(javax.xml.ws.WebServiceFeature) ProviderImpl(org.apache.cxf.jaxws.spi.ProviderImpl) Document(org.w3c.dom.Document) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Test(org.junit.Test)

Example 10 with EndpointReference

use of javax.xml.ws.EndpointReference in project cxf by apache.

the class EndpointReferenceTest method testBindingProviderSOAPBindingStaicService.

@Test
public void testBindingProviderSOAPBindingStaicService() throws Exception {
    org.apache.hello_world_soap_http.SOAPService s = new org.apache.hello_world_soap_http.SOAPService();
    Greeter greeter = s.getPort(Greeter.class);
    BindingProvider bindingProvider = (BindingProvider) greeter;
    EndpointReference er = bindingProvider.getEndpointReference();
    assertNotNull(er);
    // If the BindingProvider instance has a binding that is either SOAP 1.1/HTTP or SOAP
    // 1.2/HTTP, then a W3CEndpointReference MUST be returned.
    assertTrue(er instanceof W3CEndpointReference);
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Greeter(org.apache.hello_world_soap_http.Greeter) BindingProvider(javax.xml.ws.BindingProvider) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Test(org.junit.Test)

Aggregations

EndpointReference (javax.xml.ws.EndpointReference)11 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)10 Test (org.junit.Test)9 InputStream (java.io.InputStream)6 Document (org.w3c.dom.Document)6 Greeter (org.apache.hello_world_soap_http.Greeter)5 GreeterImpl (org.apache.hello_world_soap_http.GreeterImpl)5 DOMSource (javax.xml.transform.dom.DOMSource)4 QName (javax.xml.namespace.QName)3 WebServiceFeature (javax.xml.ws.WebServiceFeature)3 BindingProvider (javax.xml.ws.BindingProvider)2 ProviderImpl (org.apache.cxf.jaxws.spi.ProviderImpl)2 Element (org.w3c.dom.Element)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Endpoint (javax.xml.ws.Endpoint)1 W3CEndpointReferenceBuilder (javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)1 SOAPService (org.apache.callback.SOAPService)1 ServerPortType (org.apache.callback.ServerPortType)1 Greeter (org.apache.cxf.hello_world.discovery.Greeter)1