Search in sources :

Example 96 with Greeter

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

the class Client method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.out.println("please specify wsdl");
        System.exit(1);
    }
    URL wsdlURL;
    File wsdlFile = new File(args[0]);
    if (wsdlFile.exists()) {
        wsdlURL = wsdlFile.toURI().toURL();
    } else {
        wsdlURL = new URL(args[0]);
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = null;
    if ("secure".equals(args[1])) {
        busFile = Client.class.getResource("/SecureClient.xml");
    } else if ("insecure".equals(args[1])) {
        busFile = Client.class.getResource("/InsecureClient.xml");
    } else {
        System.out.println("arg1 needs to be either secure or insecure");
        System.exit(1);
    }
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    System.out.println(wsdlURL);
    SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
    Greeter port = ss.getPort(PORT_NAME, Greeter.class);
    System.out.println("Invoking greetMe...");
    try {
        String resp = port.greetMe(System.getProperty("user.name"));
        System.out.println("Server responded with: " + resp);
        System.out.println();
    } catch (Exception e) {
        System.out.println("Invocation failed with the following: " + e.getCause());
        System.out.println();
    }
    System.exit(0);
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.hello_world_soap_http.Greeter) File(java.io.File) URL(java.net.URL)

Example 97 with Greeter

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

the class ClientNonSpring method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.out.println("please specify wsdl");
        System.exit(1);
    }
    URL wsdlURL;
    File wsdlFile = new File(args[0]);
    if (wsdlFile.exists()) {
        wsdlURL = wsdlFile.toURI().toURL();
    } else {
        wsdlURL = new URL(args[0]);
    }
    System.out.println(wsdlURL);
    SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
    Greeter port = ss.getPort(PORT_NAME, Greeter.class);
    if ("secure".equals(args[1])) {
        setupTLS(port);
    } else if ("insecure".equals(args[1])) {
    // do nothing
    } else {
        System.out.println("arg1 needs to be either secure or insecure");
        System.exit(1);
    }
    System.out.println("Invoking greetMe...");
    try {
        String resp = port.greetMe(System.getProperty("user.name"));
        System.out.println("Server responded with: " + resp);
        System.out.println();
    } catch (Exception e) {
        System.out.println("Invocation failed with the following: " + e.getCause());
        System.out.println();
    }
    System.exit(0);
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Greeter(org.apache.hello_world_soap_http.Greeter) File(java.io.File) URL(java.net.URL) IOException(java.io.IOException) KeyStoreException(java.security.KeyStoreException) FileNotFoundException(java.io.FileNotFoundException) GeneralSecurityException(java.security.GeneralSecurityException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 98 with Greeter

use of org.apache.hello_world_soap_http.Greeter 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 99 with Greeter

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

the class EndpointReferenceTest method testBindingProviderSOAPBindingStaicService.

@Test
public void testBindingProviderSOAPBindingStaicService() throws Exception {
    org.apache.hello_world_soap_http.SOAPService s = new org.apache.hello_world_soap_http.SOAPService();
    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 : 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 100 with Greeter

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

the class JaxWsClientTest method testThreadLocalRequestContextIsIsolated.

@Test
public void testThreadLocalRequestContextIsIsolated() throws InterruptedException {
    URL url = getClass().getResource("/wsdl/hello_world.wsdl");
    javax.xml.ws.Service s = javax.xml.ws.Service.create(url, serviceName);
    final Greeter handler = s.getPort(portName, Greeter.class);
    final AtomicBoolean isPropertyAPresent = new AtomicBoolean(false);
    // Makes request context thread local
    ClientProxy.getClient(handler).setThreadLocalRequestContext(true);
    // PropertyA should be added to the request context of current thread only
    ClientProxy.getClient(handler).getRequestContext().put("PropertyA", "PropertyAVal");
    Runnable checkRequestContext = new Runnable() {

        @Override
        public void run() {
            if (ClientProxy.getClient(handler).getRequestContext().containsKey("PropertyA")) {
                isPropertyAPresent.set(true);
            }
        }
    };
    Thread thread = new Thread(checkRequestContext);
    thread.start();
    thread.join(60000);
    assertFalse("If we have per thread isolation propertyA should be not present in the context of another thread.", isPropertyAPresent.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Greeter(org.apache.hello_world_soap_http.Greeter) URL(java.net.URL) Test(org.junit.Test)

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