Search in sources :

Example 56 with Greeter

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

the class JSClientServerTest method testJSPayloadMode.

@Test
public void testJSPayloadMode() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    QName serviceName = new QName(NS, "SOAPService_Test1");
    QName portName = new QName(NS, "SoapPort_Test1");
    SOAPServiceTest1 service = new SOAPServiceTest1(wsdl, serviceName);
    assertNotNull(service);
    String response1 = new String("TestGreetMeResponse");
    String response2 = new String("TestSayHiResponse");
    try {
        Greeter greeter = service.getPort(portName, Greeter.class);
        updateAddressPort(greeter, JSX_PORT);
        String greeting = greeter.greetMe("TestGreetMeRequest");
        assertNotNull("no response received from service", greeting);
        assertEquals(response1, greeting);
        String reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals(response2, reply);
    } catch (UndeclaredThrowableException ex) {
        ex.printStackTrace();
        throw (Exception) ex.getCause();
    }
}
Also used : QName(javax.xml.namespace.QName) SOAPServiceTest1(org.apache.hello_world_soap_http.SOAPServiceTest1) Greeter(org.apache.hello_world_soap_http.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) URL(java.net.URL) Test(org.junit.Test)

Example 57 with Greeter

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

the class ManagedBusTest method testTwoSameNamedEndpoint.

@Test
public void testTwoSameNamedEndpoint() throws Exception {
    SpringBusFactory factory = new SpringBusFactory();
    Bus bus = factory.createBus();
    try {
        InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
        assertNotNull(im);
        InstrumentationManagerImpl imi = (InstrumentationManagerImpl) im;
        imi.setServer(ManagementFactory.getPlatformMBeanServer());
        imi.setEnabled(true);
        imi.init();
        Greeter greeter1 = new GreeterImpl();
        JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
        svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello");
        svrFactory.setServiceBean(greeter1);
        svrFactory.getProperties(true).put("managed.endpoint.name", "greeter1");
        svrFactory.create();
        Greeter greeter2 = new GreeterImpl();
        svrFactory = new JaxWsServerFactoryBean();
        svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello2");
        svrFactory.setServiceBean(greeter2);
        svrFactory.getProperties(true).put("managed.endpoint.name", "greeter2");
        svrFactory.create();
        MBeanServer mbs = im.getMBeanServer();
        ObjectName name = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":type=Bus.Service.Endpoint,*");
        Set<?> s = mbs.queryMBeans(name, null);
        assertEquals(2, s.size());
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) InstrumentationManagerImpl(org.apache.cxf.management.jmx.InstrumentationManagerImpl) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.hello_world_soap_http.Greeter) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 58 with Greeter

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

the class JarResolverTest method testResolver.

@Test
public void testResolver() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    createBus();
    assertNotNull(bus);
    ServiceContractResolverRegistryImpl registry = new ServiceContractResolverRegistryImpl();
    registry.setBus(bus);
    assertNotNull(bus.getExtension(ServiceContractResolverRegistry.class));
    JarServiceContractResolver resolver = new JarServiceContractResolver();
    registry.register(resolver);
    Service service = Service.create(serviceName);
    // service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING,
    // "http://localhost:9000/SoapContext/SoapPort");
    Greeter greeter = service.getPort(portName, Greeter.class);
    updateAddressPort(greeter, PORT);
    String resp = greeter.sayHi();
    assertNotNull(resp);
}
Also used : ServiceContractResolverRegistryImpl(org.apache.cxf.bus.managers.ServiceContractResolverRegistryImpl) Greeter(org.apache.hello_world_soap_http.Greeter) ServiceContractResolverRegistry(org.apache.cxf.endpoint.ServiceContractResolverRegistry) Service(javax.xml.ws.Service) URL(java.net.URL) Test(org.junit.Test)

Example 59 with Greeter

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

the class JettyBasicAuthTest 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");
}
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 60 with Greeter

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

the class JettyDigestAuthTest 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();
    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)

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