Search in sources :

Example 1 with EndpointReference

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

the class EndpointReferenceTest method testEndpointReferenceGetPort.

@Test
public void testEndpointReferenceGetPort() throws Exception {
    BusFactory.setDefaultBus(getBus());
    GreeterImpl greeter1 = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String) null)) {
        endpoint.publish("http://localhost:8080/test");
        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 = endpointReference.getPort(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) Document(org.w3c.dom.Document) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Test(org.junit.Test)

Example 2 with EndpointReference

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

the class EndpointReferenceTest method testBindingProviderSOAPBinding.

@Test
public void testBindingProviderSOAPBinding() throws Exception {
    javax.xml.ws.Service s = javax.xml.ws.Service.create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
    assertNotNull(s);
    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 : QName(javax.xml.namespace.QName) 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)

Example 3 with EndpointReference

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

the class EndpointReferenceTest method testProviderReadEndpointReference.

@Test
public void testProviderReadEndpointReference() throws Exception {
    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 = provider.readEndpointReference(erXML);
    assertNotNull(endpointReference);
    assertTrue(endpointReference instanceof W3CEndpointReference);
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) InputStream(java.io.InputStream) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) 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 4 with EndpointReference

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

the class EndpointReferenceTest method testServiceGetPortUsingEndpointReference.

/*
     * Any JAX-WS supported epr metadata MUST match the Service instances
     * ServiceName, otherwise a WebServiceExeption MUST be thrown. Any JAX-WS
     * supported epr metadata MUST match the PortName for the sei, otherwise a
     * WebServiceException MUST be thrown. If the Service instance has an
     * associated WSDL, its WSDL MUST be used to determine any binding
     * information, anyWSDL in a JAX-WS suppported epr metadata MUST be ignored.
     * If the Service instance does not have a WSDL, then any WSDL inlined in
     * the JAX-WS supported metadata of the epr MUST be used to determine
     * binding information. If there is not enough metadata in the Service
     * instance or in the epr metadata to determine a port, then a
     * WebServiceException MUST be thrown.
     */
@Test
public void testServiceGetPortUsingEndpointReference() throws Exception {
    BusFactory.setDefaultBus(getBus());
    GreeterImpl greeter1 = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String) null)) {
        endpoint.publish("http://localhost:8080/test");
        javax.xml.ws.Service s = javax.xml.ws.Service.create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
        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 = s.getPort(endpointReference, Greeter.class, wfs);
        String response = greeter.greetMe("John");
        assertEquals("Hello John", response);
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) QName(javax.xml.namespace.QName) InputStream(java.io.InputStream) Document(org.w3c.dom.Document) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Greeter(org.apache.hello_world_soap_http.Greeter) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) WebServiceFeature(javax.xml.ws.WebServiceFeature) Test(org.junit.Test)

Example 5 with EndpointReference

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

the class WSDiscoveryClient method probe.

public List<EndpointReference> probe(QName type) {
    ProbeType p = new ProbeType();
    if (type != null) {
        p.getTypes().add(type);
    }
    ProbeMatchesType pmt = probe(p, defaultProbeTimeout);
    List<EndpointReference> er = new ArrayList<>();
    for (ProbeMatchType pm : pmt.getProbeMatch()) {
        for (String add : pm.getXAddrs()) {
            W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
            builder.address(add);
            // builder.serviceName(type);
            // builder.endpointName(type);
            er.add(builder.build());
        }
    }
    return er;
}
Also used : W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) ProbeType(org.apache.cxf.ws.discovery.wsdl.ProbeType) ArrayList(java.util.ArrayList) ProbeMatchesType(org.apache.cxf.ws.discovery.wsdl.ProbeMatchesType) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) ProbeMatchType(org.apache.cxf.ws.discovery.wsdl.ProbeMatchType)

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