Search in sources :

Example 26 with GreeterImpl

use of org.apache.hello_world_soap_http.GreeterImpl 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 27 with GreeterImpl

use of org.apache.hello_world_soap_http.GreeterImpl in project cxf by apache.

the class EndpointReferenceTest method testEndpointGetEndpointReferenceInvalid.

@Test
public void testEndpointGetEndpointReferenceInvalid() throws Exception {
    GreeterImpl greeter = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String) null)) {
        endpoint.publish("http://localhost:8080/test");
        try {
            InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
            Document doc = StaxUtils.read(is);
            Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(), "wsa:ReferenceParameters", "");
            endpoint.getEndpointReference(MyEndpointReference.class, referenceParameters);
            fail("Did not get expected WebServiceException");
        } catch (WebServiceException e) {
        // do nothing
        }
        endpoint.stop();
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) InputStream(java.io.InputStream) Element(org.w3c.dom.Element) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 28 with GreeterImpl

use of org.apache.hello_world_soap_http.GreeterImpl in project cxf by apache.

the class Server method run.

protected void run() {
    Object implementor;
    String address;
    implementor = new GreeterImpl();
    address = "ws://localhost:" + PORT + "/SoapContext/SoapPort";
    Endpoint ep = Endpoint.publish(address, implementor);
    eps.add(ep);
    // publish port with soap12 binding
    address = "ws://localhost:" + PORT + "/SoapContext/SoapPort";
    EndpointImpl e = (EndpointImpl) Endpoint.create(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING, new Greeter12Impl());
    e.publish(address);
    eps.add(e);
}
Also used : Endpoint(javax.xml.ws.Endpoint) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) BaseGreeterImpl(org.apache.hello_world_soap_http.BaseGreeterImpl)

Aggregations

GreeterImpl (org.apache.hello_world_soap_http.GreeterImpl)28 Test (org.junit.Test)17 URL (java.net.URL)7 BeanInvoker (org.apache.cxf.service.invoker.BeanInvoker)7 InputStream (java.io.InputStream)6 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)6 Document (org.w3c.dom.Document)6 EndpointReference (javax.xml.ws.EndpointReference)5 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)5 ReflectionServiceFactoryBean (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)5 BusException (org.apache.cxf.BusException)4 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)4 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)4 Service (org.apache.cxf.service.Service)4 QName (javax.xml.namespace.QName)3 DOMSource (javax.xml.transform.dom.DOMSource)3 WebServiceContext (javax.xml.ws.WebServiceContext)3 WebServiceFeature (javax.xml.ws.WebServiceFeature)3 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)3 EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)3