javax.xml.ws.WebServiceClient Java Examples

The following examples show how to use javax.xml.ws.WebServiceClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtSoapHeaderClientServerTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void run() {
    String address0 = "http://localhost:" + PORT0 + "/SoapExtHeader/SampleService";

    Object implementor1 = new SamplePortTypeImpl();
    Endpoint.publish(address0, implementor1);

    String address1 = "http://localhost:" + PORT1 + "/SoapExtHeader/SampleService";
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setServiceClass(SamplePortTypeImpl.class);

    WebServiceClient webService = SampleService.class.getAnnotation(WebServiceClient.class);
    sf.setServiceName(new QName(webService.targetNamespace(), webService.name()));
    sf.setWsdlLocation(webService.wsdlLocation());
    sf.setAddress(address1);

    extserver = sf.create();
}
 
Example #2
Source File: CodeGenBugTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testServiceNS() throws Exception {
    env.put(ToolConstants.CFG_ALL, ToolConstants.CFG_ALL);
    env.put(ToolConstants.CFG_WSDLURL,
            getLocation("/wsdl2java_wsdl/bug321/hello_world_different_ns_service.wsdl"));
    processor.setContext(env);
    processor.execute();

    Class<?> clz = classLoader
        .loadClass("org.apache.cxf.w2j.hello_world_soap_http.service.SOAPServiceTest1");
    WebServiceClient webServiceClient = AnnotationUtil
        .getPrivClassAnnotation(clz, WebServiceClient.class);
    assertEquals("http://cxf.apache.org/w2j/hello_world_soap_http/service",
                 webServiceClient.targetNamespace());
    String file = TestFileUtils.getStringFromFile(new File(output, 
            "org/apache/cxf/w2j/hello_world_soap_http/Greeter_SoapPortTest1_Client.java"));
    assertTrue("Service QName in client is not correct", file.contains(
            "new QName(\"http://cxf.apache.org/w2j/hello_world_soap_http/service\", \"SOAPService_Test1\")"));
}
 
Example #3
Source File: SCAnnotations.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
SCAnnotations(final Class<?> sc) {
    AccessController.doPrivileged(new PrivilegedAction<Void>() {
        @Override
        public Void run() {
            WebServiceClient wsc =sc.getAnnotation(WebServiceClient.class);
            if(wsc==null) {
                throw new WebServiceException("Service Interface Annotations required, exiting...");
            }

            String tns = wsc.targetNamespace();
            try {
                JAXWSUtils.getFileOrURL(wsc.wsdlLocation());
            } catch (IOException e) {
                // TODO: report a reasonable error message
                throw new WebServiceException(e);
            }

            for (Method method : sc.getDeclaredMethods()) {
                WebEndpoint webEndpoint = method.getAnnotation(WebEndpoint.class);
                if (webEndpoint != null) {
                    String endpointName = webEndpoint.name();
                    QName portQName = new QName(tns, endpointName);
                    portQNames.add(portQName);
                }
                Class<?> seiClazz = method.getReturnType();
                if (seiClazz!=void.class) {
                    classes.add(seiClazz);
                }
            }

            return null;
        }
    });
}
 
Example #4
Source File: SCAnnotations.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
SCAnnotations(final Class<?> sc) {
    AccessController.doPrivileged(new PrivilegedAction<Void>() {
        @Override
        public Void run() {
            WebServiceClient wsc =sc.getAnnotation(WebServiceClient.class);
            if(wsc==null) {
                throw new WebServiceException("Service Interface Annotations required, exiting...");
            }

            String tns = wsc.targetNamespace();
            try {
                JAXWSUtils.getFileOrURL(wsc.wsdlLocation());
            } catch (IOException e) {
                // TODO: report a reasonable error message
                throw new WebServiceException(e);
            }

            for (Method method : sc.getDeclaredMethods()) {
                WebEndpoint webEndpoint = method.getAnnotation(WebEndpoint.class);
                if (webEndpoint != null) {
                    String endpointName = webEndpoint.name();
                    QName portQName = new QName(tns, endpointName);
                    portQNames.add(portQName);
                }
                Class<?> seiClazz = method.getReturnType();
                if (seiClazz!=void.class) {
                    classes.add(seiClazz);
                }
            }

            return null;
        }
    });
}
 
Example #5
Source File: SCAnnotations.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
SCAnnotations(final Class<?> sc) {
    AccessController.doPrivileged(new PrivilegedAction<Void>() {
        @Override
        public Void run() {
            WebServiceClient wsc =sc.getAnnotation(WebServiceClient.class);
            if(wsc==null) {
                throw new WebServiceException("Service Interface Annotations required, exiting...");
            }

            String tns = wsc.targetNamespace();
            try {
                JAXWSUtils.getFileOrURL(wsc.wsdlLocation());
            } catch (IOException e) {
                // TODO: report a reasonable error message
                throw new WebServiceException(e);
            }

            for (Method method : sc.getDeclaredMethods()) {
                WebEndpoint webEndpoint = method.getAnnotation(WebEndpoint.class);
                if (webEndpoint != null) {
                    String endpointName = webEndpoint.name();
                    QName portQName = new QName(tns, endpointName);
                    portQNames.add(portQName);
                }
                Class<?> seiClazz = method.getReturnType();
                if (seiClazz!=void.class) {
                    classes.add(seiClazz);
                }
            }

            return null;
        }
    });
}
 
Example #6
Source File: SCAnnotations.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
SCAnnotations(final Class<?> sc) {
    AccessController.doPrivileged(new PrivilegedAction<Void>() {
        @Override
        public Void run() {
            WebServiceClient wsc =sc.getAnnotation(WebServiceClient.class);
            if(wsc==null) {
                throw new WebServiceException("Service Interface Annotations required, exiting...");
            }

            String tns = wsc.targetNamespace();
            try {
                JAXWSUtils.getFileOrURL(wsc.wsdlLocation());
            } catch (IOException e) {
                // TODO: report a reasonable error message
                throw new WebServiceException(e);
            }

            for (Method method : sc.getDeclaredMethods()) {
                WebEndpoint webEndpoint = method.getAnnotation(WebEndpoint.class);
                if (webEndpoint != null) {
                    String endpointName = webEndpoint.name();
                    QName portQName = new QName(tns, endpointName);
                    portQNames.add(portQName);
                }
                Class<?> seiClazz = method.getReturnType();
                if (seiClazz!=void.class) {
                    classes.add(seiClazz);
                }
            }

            return null;
        }
    });
}
 
Example #7
Source File: SCAnnotations.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
SCAnnotations(final Class<?> sc) {
    AccessController.doPrivileged(new PrivilegedAction<Void>() {
        @Override
        public Void run() {
            WebServiceClient wsc =sc.getAnnotation(WebServiceClient.class);
            if(wsc==null) {
                throw new WebServiceException("Service Interface Annotations required, exiting...");
            }

            String tns = wsc.targetNamespace();
            try {
                JAXWSUtils.getFileOrURL(wsc.wsdlLocation());
            } catch (IOException e) {
                // TODO: report a reasonable error message
                throw new WebServiceException(e);
            }

            for (Method method : sc.getDeclaredMethods()) {
                WebEndpoint webEndpoint = method.getAnnotation(WebEndpoint.class);
                if (webEndpoint != null) {
                    String endpointName = webEndpoint.name();
                    QName portQName = new QName(tns, endpointName);
                    portQNames.add(portQName);
                }
                Class<?> seiClazz = method.getReturnType();
                if (seiClazz!=void.class) {
                    classes.add(seiClazz);
                }
            }

            return null;
        }
    });
}
 
Example #8
Source File: SCAnnotations.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
SCAnnotations(final Class<?> sc) {
    AccessController.doPrivileged(new PrivilegedAction<Void>() {
        @Override
        public Void run() {
            WebServiceClient wsc =sc.getAnnotation(WebServiceClient.class);
            if(wsc==null) {
                throw new WebServiceException("Service Interface Annotations required, exiting...");
            }

            String tns = wsc.targetNamespace();
            try {
                JAXWSUtils.getFileOrURL(wsc.wsdlLocation());
            } catch (IOException e) {
                // TODO: report a reasonable error message
                throw new WebServiceException(e);
            }

            for (Method method : sc.getDeclaredMethods()) {
                WebEndpoint webEndpoint = method.getAnnotation(WebEndpoint.class);
                if (webEndpoint != null) {
                    String endpointName = webEndpoint.name();
                    QName portQName = new QName(tns, endpointName);
                    portQNames.add(portQName);
                }
                Class<?> seiClazz = method.getReturnType();
                if (seiClazz!=void.class) {
                    classes.add(seiClazz);
                }
            }

            return null;
        }
    });
}
 
Example #9
Source File: SCAnnotations.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
SCAnnotations(final Class<?> sc) {
    AccessController.doPrivileged(new PrivilegedAction<Void>() {
        @Override
        public Void run() {
            WebServiceClient wsc =sc.getAnnotation(WebServiceClient.class);
            if(wsc==null) {
                throw new WebServiceException("Service Interface Annotations required, exiting...");
            }

            String tns = wsc.targetNamespace();
            try {
                JAXWSUtils.getFileOrURL(wsc.wsdlLocation());
            } catch (IOException e) {
                // TODO: report a reasonable error message
                throw new WebServiceException(e);
            }

            for (Method method : sc.getDeclaredMethods()) {
                WebEndpoint webEndpoint = method.getAnnotation(WebEndpoint.class);
                if (webEndpoint != null) {
                    String endpointName = webEndpoint.name();
                    QName portQName = new QName(tns, endpointName);
                    portQNames.add(portQName);
                }
                Class<?> seiClazz = method.getReturnType();
                if (seiClazz!=void.class) {
                    classes.add(seiClazz);
                }
            }

            return null;
        }
    });
}
 
Example #10
Source File: SCAnnotations.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
SCAnnotations(final Class<?> sc) {
    AccessController.doPrivileged(new PrivilegedAction<Void>() {
        @Override
        public Void run() {
            WebServiceClient wsc =sc.getAnnotation(WebServiceClient.class);
            if(wsc==null) {
                throw new WebServiceException("Service Interface Annotations required, exiting...");
            }

            String tns = wsc.targetNamespace();
            try {
                JAXWSUtils.getFileOrURL(wsc.wsdlLocation());
            } catch (IOException e) {
                // TODO: report a reasonable error message
                throw new WebServiceException(e);
            }

            for (Method method : sc.getDeclaredMethods()) {
                WebEndpoint webEndpoint = method.getAnnotation(WebEndpoint.class);
                if (webEndpoint != null) {
                    String endpointName = webEndpoint.name();
                    QName portQName = new QName(tns, endpointName);
                    portQNames.add(portQName);
                }
                Class<?> seiClazz = method.getReturnType();
                if (seiClazz!=void.class) {
                    classes.add(seiClazz);
                }
            }

            return null;
        }
    });
}
 
Example #11
Source File: JaxWsUtils.java    From tomee with Apache License 2.0 5 votes vote down vote up
public static QName getServiceQName(final Class<?> clazz) {
    final WebService webService = clazz.getAnnotation(WebService.class);
    if (webService != null) {
        return getServiceQName(clazz, webService.targetNamespace(), webService.serviceName());
    }
    final WebServiceProvider webServiceProvider = clazz.getAnnotation(WebServiceProvider.class);
    if (webServiceProvider != null) {
        return getServiceQName(clazz, webServiceProvider.targetNamespace(), webServiceProvider.serviceName());
    }
    final WebServiceClient webServiceClient = clazz.getAnnotation(WebServiceClient.class);
    if (webServiceClient != null) {
        return getServiceQName(clazz, webServiceClient.targetNamespace(), webServiceClient.name());
    }
    throw new IllegalArgumentException("The " + clazz.getName() + " is not annotated");
}