Search in sources :

Example 11 with Greeter

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

the class NoSpringServletClientTest method testBasicConnection.

@Test
public void testBasicConnection() throws Exception {
    SOAPService service = new SOAPService(new URL(serviceURL + "Greeter?wsdl"));
    Greeter greeter = service.getPort(portName, Greeter.class);
    try {
        String reply = greeter.greetMe("test");
        assertNotNull("no response received from service", reply);
        assertEquals("Hello test", reply);
        reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals("Bonjour", reply);
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Greeter(org.apache.hello_world_soap_http.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) URL(java.net.URL) Test(org.junit.Test)

Example 12 with Greeter

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

the class BusShutdownTest method doWork.

private void doWork(URL wsdlUrl, String address) {
    SOAPService service = new SOAPService(wsdlUrl);
    assertNotNull(service);
    Greeter greeter = service.getSoapPort();
    // overwrite client address
    InvocationHandler handler = Proxy.getInvocationHandler(greeter);
    BindingProvider bp = (BindingProvider) handler;
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
    Client client = ClientProxy.getClient(greeter);
    HTTPConduit c = (HTTPConduit) client.getConduit();
    c.setClient(new HTTPClientPolicy());
    c.getClient().setConnection(ConnectionType.CLOSE);
    // invoke twoway call
    greeter.sayHi();
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) Greeter(org.apache.hello_world_soap_http.Greeter) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) BindingProvider(javax.xml.ws.BindingProvider) Client(org.apache.cxf.endpoint.Client) InvocationHandler(java.lang.reflect.InvocationHandler)

Example 13 with Greeter

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

the class WSAFaultToClientServerTest method testOneWayFaultTo.

@Test
public void testOneWayFaultTo() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPServiceAddressing");
    Greeter greeter = new SOAPService(wsdl, serviceName).getPort(Greeter.class, new AddressingFeature());
    EndpointReferenceType faultTo = new EndpointReferenceType();
    AddressingProperties addrProperties = new AddressingProperties();
    AttributedURIType epr = new AttributedURIType();
    String faultToAddress = "http://localhost:" + FaultToEndpointServer.FAULT_PORT + "/faultTo";
    epr.setValue(faultToAddress);
    faultTo.setAddress(epr);
    addrProperties.setFaultTo(faultTo);
    BindingProvider provider = (BindingProvider) greeter;
    Map<String, Object> requestContext = provider.getRequestContext();
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + FaultToEndpointServer.PORT + "/jaxws/greeter");
    requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addrProperties);
    greeter.greetMeOneWay("test");
    // wait for the fault request
    int i = 2;
    while (HelloHandler.getFaultRequestPath() == null && i > 0) {
        Thread.sleep(500);
        i--;
    }
    assertTrue("FaultTo request fpath isn't expected", "/faultTo".equals(HelloHandler.getFaultRequestPath()));
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) AddressingFeature(javax.xml.ws.soap.AddressingFeature) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) QName(javax.xml.namespace.QName) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Greeter(org.apache.hello_world_soap_http.Greeter) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) Test(org.junit.Test)

Example 14 with Greeter

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

the class MAPTestBase method createGreeter.

public Greeter createGreeter(EndpointReferenceType target) throws Exception {
    ServiceImpl serviceImpl = ServiceDelegateAccessor.get(new SOAPService(getWSDLURL(), SERVICE_NAME));
    Greeter g = serviceImpl.getPort(target, Greeter.class);
    updateAddressPort(g, getPort());
    return g;
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) Greeter(org.apache.hello_world_soap_http.Greeter)

Example 15 with Greeter

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

the class WSAFeatureXmlTest method testClientProxyFactory.

@Test
public void testClientProxyFactory() {
    JaxWsProxyFactoryBean cf = new JaxWsProxyFactoryBean();
    cf.setAddress("http://localhost:" + PORT + "/test");
    cf.setServiceClass(Greeter.class);
    cf.setBus(getBus());
    Configurer c = getBus().getExtension(Configurer.class);
    c.configureBean("client.proxyFactory", cf);
    Greeter greeter = (Greeter) cf.create();
    Client client = ClientProxy.getClient(greeter);
    checkAddressInterceptors(client.getInInterceptors());
}
Also used : Greeter(org.apache.hello_world_soap_http.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Configurer(org.apache.cxf.configuration.Configurer) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test) AbstractCXFTest(org.apache.cxf.test.AbstractCXFTest)

Aggregations

Greeter (org.apache.hello_world_soap_http.Greeter)104 Test (org.junit.Test)78 SOAPService (org.apache.hello_world_soap_http.SOAPService)55 URL (java.net.URL)47 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)24 BindingProvider (javax.xml.ws.BindingProvider)23 SOAPServiceBogusAddressTest (org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest)21 SOAPServiceMultiPortTypeTest (org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest)21 Service (javax.xml.ws.Service)19 Client (org.apache.cxf.endpoint.Client)17 Endpoint (javax.xml.ws.Endpoint)13 QName (javax.xml.namespace.QName)10 Bus (org.apache.cxf.Bus)10 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)10 ExecutorService (java.util.concurrent.ExecutorService)9 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)7 File (java.io.File)6 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)6 GreetMeLaterResponse (org.apache.hello_world_soap_http.types.GreetMeLaterResponse)6 InvocationHandler (java.lang.reflect.InvocationHandler)5