Search in sources :

Example 71 with SOAPService

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

the class UndertowBasicAuthTest method setUp.

@Before
public void setUp() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    greeter = new SOAPService(wsdl, SERVICE_NAME).getPort(Greeter.class);
    BindingProvider bp = (BindingProvider) greeter;
    ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor());
    ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor());
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS);
    bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "ffang");
    bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");
    greeter1 = new SOAPService(wsdl, SERVICE_NAME).getPort(Greeter.class);
    bp = (BindingProvider) greeter1;
    ClientProxy.getClient(greeter1).getInInterceptors().add(new LoggingInInterceptor());
    ClientProxy.getClient(greeter1).getOutInterceptors().add(new LoggingOutInterceptor());
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS1);
    bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "ffang");
    bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) Greeter(org.apache.hello_world_soap_http.Greeter) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Before(org.junit.Before)

Example 72 with SOAPService

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

the class UndertowDigestAuthTest method setupClient.

private HTTPConduit setupClient(boolean async) throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    greeter = new SOAPService(wsdl, SERVICE_NAME).getPort(Greeter.class);
    BindingProvider bp = (BindingProvider) greeter;
    ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor());
    ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor());
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS);
    HTTPConduit cond = (HTTPConduit) ClientProxy.getClient(greeter).getConduit();
    HTTPClientPolicy client = new HTTPClientPolicy();
    client.setConnectionTimeout(600000);
    client.setReceiveTimeout(600000);
    cond.setClient(client);
    if (async) {
        if (cond instanceof AsyncHTTPConduit) {
            UsernamePasswordCredentials creds = new UsernamePasswordCredentials("ffang", "pswd");
            bp.getRequestContext().put(Credentials.class.getName(), creds);
            bp.getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
            client.setAutoRedirect(true);
        } else {
            fail("Not an async conduit");
        }
    } else {
        bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "ffang");
        bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");
        cond.setAuthSupplier(new DigestAuthSupplier());
    }
    ClientProxy.getClient(greeter).getOutInterceptors().add(new AbstractPhaseInterceptor<Message>(Phase.PRE_STREAM_ENDING) {

        public void handleMessage(Message message) throws Fault {
            Map<String, ?> headers = CastUtils.cast((Map<?, ?>) message.get(Message.PROTOCOL_HEADERS));
            if (headers.containsKey("Proxy-Authorization")) {
                throw new RuntimeException("Should not have Proxy-Authorization");
            }
        }
    });
    client.setAllowChunking(false);
    return cond;
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) DigestAuthSupplier(org.apache.cxf.transport.http.auth.DigestAuthSupplier) Message(org.apache.cxf.message.Message) Fault(org.apache.cxf.interceptor.Fault) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) AsyncHTTPConduit(org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduit) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) AsyncHTTPConduit(org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduit) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) Greeter(org.apache.hello_world_soap_http.Greeter) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Map(java.util.Map) Credentials(org.apache.http.auth.Credentials) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials)

Example 73 with SOAPService

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

the class OutBoundConnectionTest method testBasicConnection.

@Test
@org.junit.Ignore
public void testBasicConnection() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    SOAPService service = new SOAPService(wsdl, serviceName);
    assertNotNull(service);
    CXFConnectionRequestInfo cri = new CXFConnectionRequestInfo(Greeter.class, wsdl, service.getServiceName(), portName);
    cri.setAddress("http://localhost:" + PORT + "/SoapContext/SoapPort");
    ManagedConnectionFactory managedFactory = new ManagedConnectionFactoryImpl();
    Subject subject = new Subject();
    ManagedConnection mc = managedFactory.createManagedConnection(subject, cri);
    Object o = mc.getConnection(subject, cri);
    // test for the Object hash()
    try {
        o.hashCode();
        o.toString();
    } catch (WebServiceException ex) {
        fail("The connection object should support Object method");
    }
    verifyResult(o);
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) ManagedConnectionFactory(javax.resource.spi.ManagedConnectionFactory) WebServiceException(javax.xml.ws.WebServiceException) CXFConnectionRequestInfo(org.apache.cxf.jca.cxf.CXFConnectionRequestInfo) ManagedConnectionFactoryImpl(org.apache.cxf.jca.cxf.ManagedConnectionFactoryImpl) ManagedConnection(javax.resource.spi.ManagedConnection) URL(java.net.URL) Subject(javax.security.auth.Subject) Test(org.junit.Test)

Example 74 with SOAPService

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

the class CountersClientServerTest method testCountersWithInstrumentationManager.

@Test
public void testCountersWithInstrumentationManager() throws Exception {
    // create Client with other bus
    Bus bus = getStaticBus();
    BusFactory.setDefaultBus(bus);
    bus.getExtension(WorkQueueManager.class);
    CounterRepository cr = bus.getExtension(CounterRepository.class);
    InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
    assertNotNull(im);
    InstrumentationManagerImpl impl = (InstrumentationManagerImpl) im;
    assertTrue(impl.isEnabled());
    assertNotNull(impl.getMBeanServer());
    MBeanServer mbs = im.getMBeanServer();
    ObjectName name = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":" + ManagementConstants.BUS_ID_PROP + "=cxf" + bus.hashCode() + ",*");
    SOAPService service = new SOAPService();
    assertNotNull(service);
    Greeter greeter = service.getPort(portName, Greeter.class);
    updateAddressPort(greeter, PORT);
    String response = new String("Bonjour");
    String reply = greeter.sayHi();
    // assertNotNull("no response received from service", reply);
    // assertEquals(response, reply);
    assertEquals("The Counters are not create yet", 4, cr.getCounters().size());
    Set<?> counterNames = mbs.queryNames(name, null);
    assertEquals("The Counters are not export to JMX: " + counterNames, 4 + 3, counterNames.size());
    ObjectName sayHiCounter = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":operation=\"sayHi\",*");
    Set<?> s = mbs.queryNames(sayHiCounter, null);
    Iterator<?> it = s.iterator();
    while (it.hasNext()) {
        ObjectName counterName = (ObjectName) it.next();
        Object val = mbs.getAttribute(counterName, "NumInvocations");
        assertEquals("Wrong Counters Number of Invocations", val, 1);
    }
    reply = greeter.sayHi();
    assertNotNull("no response received from service", reply);
    assertEquals(response, reply);
    s = mbs.queryNames(sayHiCounter, null);
    it = s.iterator();
    while (it.hasNext()) {
        ObjectName counterName = (ObjectName) it.next();
        Object val = mbs.getAttribute(counterName, "NumInvocations");
        assertEquals("Wrong Counters Number of Invocations", val, 2);
    }
    greeter.greetMeOneWay("hello");
    for (int count = 0; count < 10; count++) {
        if (6 != cr.getCounters().size()) {
            Thread.sleep(100);
        } else {
            break;
        }
    }
    assertEquals("The Counters are not create yet", 6, cr.getCounters().size());
    for (int count = 0; count < 10; count++) {
        if (10 > mbs.queryNames(name, null).size()) {
            Thread.sleep(100);
        } else {
            break;
        }
    }
    counterNames = mbs.queryNames(name, null);
    assertEquals("The Counters are not export to JMX " + counterNames, 6 + 4, counterNames.size());
    ObjectName greetMeOneWayCounter = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":operation=\"greetMeOneWay\",*");
    s = mbs.queryNames(greetMeOneWayCounter, null);
    it = s.iterator();
    while (it.hasNext()) {
        ObjectName counterName = (ObjectName) it.next();
        Object val = mbs.getAttribute(counterName, "NumInvocations");
        assertEquals("Wrong Counters Number of Invocations", val, 1);
    }
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Bus(org.apache.cxf.Bus) CounterRepository(org.apache.cxf.management.counters.CounterRepository) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) Endpoint(javax.xml.ws.Endpoint) ObjectName(javax.management.ObjectName) InstrumentationManagerImpl(org.apache.cxf.management.jmx.InstrumentationManagerImpl) Greeter(org.apache.hello_world_soap_http.Greeter) MBeanServer(javax.management.MBeanServer) Test(org.junit.Test)

Example 75 with SOAPService

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

the class ManagedClientServerTest method testManagedEndpoint.

@Test
public void testManagedEndpoint() throws Exception {
    Bus bus = getStaticBus();
    BusFactory.setDefaultBus(bus);
    InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
    assertNotNull(im);
    InstrumentationManagerImpl impl = (InstrumentationManagerImpl) im;
    assertTrue(impl.isEnabled());
    assertNotNull(impl.getMBeanServer());
    MBeanServer mbs = im.getMBeanServer();
    ObjectName name = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":type=Bus.Service.Endpoint,*");
    Set<?> s = mbs.queryNames(name, null);
    assertEquals(1, s.size());
    name = (ObjectName) s.iterator().next();
    Object val = mbs.invoke(name, "getState", new Object[0], new String[0]);
    assertEquals("Service should have been started.", "STARTED", val);
    SOAPService service = new SOAPService();
    assertNotNull(service);
    Greeter greeter = service.getPort(portName, Greeter.class);
    updateAddressPort(greeter, PORT);
    String response = new String("Bonjour");
    String reply = greeter.sayHi();
    assertNotNull("no response received from service", reply);
    assertEquals(response, reply);
    mbs.invoke(name, "stop", new Object[0], new String[0]);
    val = mbs.getAttribute(name, "State");
    assertEquals("Service should have been stopped.", "STOPPED", val);
    try {
        reply = greeter.sayHi();
        fail("Endpoint should not be active at this point.");
    } catch (Exception ex) {
    // Expected
    }
    mbs.invoke(name, "start", new Object[0], new String[0]);
    val = mbs.invoke(name, "getState", new Object[0], new String[0]);
    assertEquals("Service should have been started.", "STARTED", val);
    reply = greeter.sayHi();
    assertNotNull("no response received from service", reply);
    assertEquals(response, reply);
    mbs.invoke(name, "destroy", new Object[0], new String[0]);
    try {
        mbs.getMBeanInfo(name);
        fail("destroy failed to unregister MBean.");
    } catch (InstanceNotFoundException e) {
    // Expected
    }
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Bus(org.apache.cxf.Bus) InstrumentationManagerImpl(org.apache.cxf.management.jmx.InstrumentationManagerImpl) Greeter(org.apache.hello_world_soap_http.Greeter) InstanceNotFoundException(javax.management.InstanceNotFoundException) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

SOAPService (org.apache.hello_world_soap_http.SOAPService)84 URL (java.net.URL)67 Test (org.junit.Test)56 Greeter (org.apache.hello_world_soap_http.Greeter)49 InputStream (java.io.InputStream)20 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)18 SOAPMessage (javax.xml.soap.SOAPMessage)14 Bus (org.apache.cxf.Bus)14 BindingProvider (javax.xml.ws.BindingProvider)13 Endpoint (javax.xml.ws.Endpoint)13 SOAPServiceBogusAddressTest (org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest)13 SOAPServiceMultiPortTypeTest (org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest)13 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)12 TimeoutException (java.util.concurrent.TimeoutException)8 WebServiceException (javax.xml.ws.WebServiceException)8 File (java.io.File)7 ExecutionException (java.util.concurrent.ExecutionException)7 QName (javax.xml.namespace.QName)7 BeforeClass (org.junit.BeforeClass)7 GreetMeLaterResponse (org.apache.hello_world_soap_http.types.GreetMeLaterResponse)6