javax.jws.WebService Java Examples

The following examples show how to use javax.jws.WebService. 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: WebServiceVisitor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected boolean shouldProcessMethod(ExecutableElement method, WebMethod webMethod) {
    builder.log("should process method: " + method.getSimpleName() + " hasWebMethods: " + hasWebMethods + " ");
    /*
    Fix for https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577
    if (hasWebMethods && webMethod == null) {
        builder.log("webMethod == null");
        return false;
    }
    */
    Collection<Modifier> modifiers = method.getModifiers();
    boolean staticFinal = modifiers.contains(Modifier.STATIC) || modifiers.contains(Modifier.FINAL);
    if (staticFinal) {
        if (webMethod != null) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_STATIC_OR_FINAL(method.getEnclosingElement(),
                    method), method);
        }
        return false;
    }
    boolean result = (endpointReferencesInterface ||
            method.getEnclosingElement().equals(typeElement) ||
            (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("endpointReferencesInterface: " + endpointReferencesInterface);
    builder.log("declaring class has WebService: " + (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("returning: " + result);
    return result;
}
 
Example #2
Source File: WebServiceVisitor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected boolean shouldProcessMethod(ExecutableElement method, WebMethod webMethod) {
    builder.log("should process method: " + method.getSimpleName() + " hasWebMethods: " + hasWebMethods + " ");
    /*
    Fix for https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577
    if (hasWebMethods && webMethod == null) {
        builder.log("webMethod == null");
        return false;
    }
    */
    Collection<Modifier> modifiers = method.getModifiers();
    boolean staticFinal = modifiers.contains(Modifier.STATIC) || modifiers.contains(Modifier.FINAL);
    if (staticFinal) {
        if (webMethod != null) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_STATIC_OR_FINAL(method.getEnclosingElement(),
                    method), method);
        }
        return false;
    }
    boolean result = (endpointReferencesInterface ||
            method.getEnclosingElement().equals(typeElement) ||
            (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("endpointReferencesInterface: " + endpointReferencesInterface);
    builder.log("declaring class has WebService: " + (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("returning: " + result);
    return result;
}
 
Example #3
Source File: JaxWsPortClientInterceptor.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Initialize the JAX-WS port for this interceptor.
 */
public void prepare() {
	Class<?> ifc = getServiceInterface();
	Assert.notNull(ifc, "Property 'serviceInterface' is required");

	WebService ann = ifc.getAnnotation(WebService.class);
	if (ann != null) {
		applyDefaultsFromAnnotation(ann);
	}

	Service serviceToUse = getJaxWsService();
	if (serviceToUse == null) {
		serviceToUse = createJaxWsService();
	}

	this.portQName = getQName(getPortName() != null ? getPortName() : ifc.getName());
	Object stub = getPortStub(serviceToUse, (getPortName() != null ? this.portQName : null));
	preparePortStub(stub);
	this.portStub = stub;
}
 
Example #4
Source File: JaxWsPortClientInterceptor.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initialize the JAX-WS port for this interceptor.
 */
public void prepare() {
	Class<?> ifc = getServiceInterface();
	if (ifc == null) {
		throw new IllegalArgumentException("Property 'serviceInterface' is required");
	}
	WebService ann = ifc.getAnnotation(WebService.class);
	if (ann != null) {
		applyDefaultsFromAnnotation(ann);
	}
	Service serviceToUse = getJaxWsService();
	if (serviceToUse == null) {
		serviceToUse = createJaxWsService();
	}
	this.portQName = getQName(getPortName() != null ? getPortName() : getServiceInterface().getName());
	Object stub = getPortStub(serviceToUse, (getPortName() != null ? this.portQName : null));
	preparePortStub(stub);
	this.portStub = stub;
}
 
Example #5
Source File: WebServiceVisitor.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected boolean shouldProcessMethod(ExecutableElement method, WebMethod webMethod) {
    builder.log("should process method: " + method.getSimpleName() + " hasWebMethods: " + hasWebMethods + " ");
    /*
    Fix for https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577
    if (hasWebMethods && webMethod == null) {
        builder.log("webMethod == null");
        return false;
    }
    */
    Collection<Modifier> modifiers = method.getModifiers();
    boolean staticFinal = modifiers.contains(Modifier.STATIC) || modifiers.contains(Modifier.FINAL);
    if (staticFinal) {
        if (webMethod != null) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_STATIC_OR_FINAL(method.getEnclosingElement(),
                    method), method);
        }
        return false;
    }
    boolean result = (endpointReferencesInterface ||
            method.getEnclosingElement().equals(typeElement) ||
            (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("endpointReferencesInterface: " + endpointReferencesInterface);
    builder.log("declaring class has WebService: " + (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("returning: " + result);
    return result;
}
 
Example #6
Source File: CodeGenBugTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testCXF1048() throws Exception {

    env.put(ToolConstants.CFG_COMPILE, "compile");
    env.put(ToolConstants.CFG_IMPL, ToolConstants.CFG_IMPL);
    env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    env.put(ToolConstants.CFG_CLASSDIR, output.getCanonicalPath() + "/classes");
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/cxf1048/test.wsdl"));
    processor.setContext(env);
    processor.execute();
    Class<?> clz = classLoader.loadClass("org.apache.hello_world_soap_http.PingSoapPortImpl");

    WebService webServiceAnn = AnnotationUtil.getPrivClassAnnotation(clz, WebService.class);
    assertEquals("org.apache.hello_world_soap_http.Ping", webServiceAnn.endpointInterface());
    assertEquals("GreeterSOAPService", webServiceAnn.serviceName());
    assertEquals("PingSoapPort", webServiceAnn.portName());
}
 
Example #7
Source File: JaxWsPortClientInterceptor.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize the JAX-WS port for this interceptor.
 */
public void prepare() {
	Class<?> ifc = getServiceInterface();
	if (ifc == null) {
		throw new IllegalArgumentException("Property 'serviceInterface' is required");
	}
	WebService ann = ifc.getAnnotation(WebService.class);
	if (ann != null) {
		applyDefaultsFromAnnotation(ann);
	}
	Service serviceToUse = getJaxWsService();
	if (serviceToUse == null) {
		serviceToUse = createJaxWsService();
	}
	this.portQName = getQName(getPortName() != null ? getPortName() : getServiceInterface().getName());
	Object stub = getPortStub(serviceToUse, (getPortName() != null ? this.portQName : null));
	preparePortStub(stub);
	this.portStub = stub;
}
 
Example #8
Source File: JaxWsBeanPostProcessor.java    From bearchoke with Apache License 2.0 6 votes vote down vote up
@Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (isWebService(bean)) {
            Bus bus = beanFactory.getBean(Bus.DEFAULT_BUS_ID, Bus.class);
            EndpointDefinitionParser.SpringEndpointImpl endpoint = new EndpointDefinitionParser.SpringEndpointImpl(bus, bean);

            WebService ws = bean.getClass().getAnnotation(WebService.class);
            endpoint.setAddress("/" + ws.serviceName());

            // capitalization is just a nice feature - totally optional
//            endpoint.setAddress("/" + StringUtils.capitalize(beanName));

            // adds ALL features registered / discovered by Spring
            Map<String, AbstractFeature> featureMap = beanFactory.getBeansOfType(AbstractFeature.class);
            endpoint.getFeatures().addAll(featureMap.values());

            // publish bean
            endpoint.publish();
        }

        return bean;
    }
 
Example #9
Source File: WebServiceVisitor.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected boolean shouldProcessMethod(ExecutableElement method, WebMethod webMethod) {
    builder.log("should process method: " + method.getSimpleName() + " hasWebMethods: " + hasWebMethods + " ");
    /*
    Fix for https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577
    if (hasWebMethods && webMethod == null) {
        builder.log("webMethod == null");
        return false;
    }
    */
    Collection<Modifier> modifiers = method.getModifiers();
    boolean staticFinal = modifiers.contains(Modifier.STATIC) || modifiers.contains(Modifier.FINAL);
    if (staticFinal) {
        if (webMethod != null) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_STATIC_OR_FINAL(method.getEnclosingElement(),
                    method), method);
        }
        return false;
    }
    boolean result = (endpointReferencesInterface ||
            method.getEnclosingElement().equals(typeElement) ||
            (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("endpointReferencesInterface: " + endpointReferencesInterface);
    builder.log("declaring class has WebService: " + (method.getEnclosingElement().getAnnotation(WebService.class) != null));
    builder.log("returning: " + result);
    return result;
}
 
Example #10
Source File: WebServiceVisitor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void verifySeiAnnotations(WebService webService, TypeElement d) {
    if (webService.endpointInterface().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_ENDPOINTINTERFACE_ON_INTERFACE(
                d.getQualifiedName(), webService.endpointInterface()), d);
    }
    if (webService.serviceName().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT(
                "serviceName", d.getQualifiedName()), d);
    }
    if (webService.portName().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT(
                "portName", d.getQualifiedName()), d);
    }
}
 
Example #11
Source File: JaxWsUtils.java    From tomee with Apache License 2.0 5 votes vote down vote up
public static QName getPortQName(final Class<?> clazz) {
    final WebService webService = clazz.getAnnotation(WebService.class);
    if (webService != null) {
        return getPortQName(clazz, webService.targetNamespace(), webService.name(), webService.portName());
    }

    final WebServiceProvider webServiceProvider = clazz.getAnnotation(WebServiceProvider.class);
    if (webServiceProvider != null) {
        return getPortQName(clazz, webServiceProvider.targetNamespace(), null, webServiceProvider.portName());
    }

    throw new IllegalArgumentException("The " + clazz.getName() + " is not annotated");
}
 
Example #12
Source File: EventSinkInterfaceNotificationTask.java    From cxf with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({
    "unchecked", "rawtypes"
})
protected JAXBElement<?> convertToJAXBElement(Object evt) {
    final Class<?> eventClass = evt.getClass();
    String tns = endpointInterface.getAnnotation(WebService.class).targetNamespace();
    return new JAXBElement(new QName(tns, eventClass.getName()), eventClass, evt);
}
 
Example #13
Source File: AbstractJaxWsServiceExporter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Publish all {@link javax.jws.WebService} annotated beans in the
 * containing BeanFactory.
 * @see #publishEndpoint
 */
public void publishEndpoints() {
	Set<String> beanNames = new LinkedHashSet<String>(this.beanFactory.getBeanDefinitionCount());
	beanNames.addAll(Arrays.asList(this.beanFactory.getBeanDefinitionNames()));
	if (this.beanFactory instanceof ConfigurableBeanFactory) {
		beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames()));
	}
	for (String beanName : beanNames) {
		try {
			Class<?> type = this.beanFactory.getType(beanName);
			if (type != null && !type.isInterface()) {
				WebService wsAnnotation = type.getAnnotation(WebService.class);
				WebServiceProvider wsProviderAnnotation = type.getAnnotation(WebServiceProvider.class);
				if (wsAnnotation != null || wsProviderAnnotation != null) {
					Endpoint endpoint = createEndpoint(this.beanFactory.getBean(beanName));
					if (this.endpointProperties != null) {
						endpoint.setProperties(this.endpointProperties);
					}
					if (this.executor != null) {
						endpoint.setExecutor(this.executor);
					}
					if (wsAnnotation != null) {
						publishEndpoint(endpoint, wsAnnotation);
					}
					else {
						publishEndpoint(endpoint, wsProviderAnnotation);
					}
					this.publishedEndpoints.add(endpoint);
				}
			}
		}
		catch (CannotLoadBeanClassException ex) {
			// ignore beans where the class is not resolvable
		}
	}
}
 
Example #14
Source File: WsgenOptions.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get an implementation class annotated with @WebService annotation.
 */
private void validateEndpointClass() throws BadCommandLineException {
    Class clazz = null;
    for(String cls : endpoints){
        clazz = getClass(cls);
        if (clazz == null)
            continue;

        if (clazz.isEnum() || clazz.isInterface() ||
            clazz.isPrimitive()) {
            continue;
        }
        isImplClass = true;
        WebService webService = (WebService) clazz.getAnnotation(WebService.class);
        if(webService == null)
            continue;
        break;
    }
    if(clazz == null){
        throw new BadCommandLineException(WscompileMessages.WSGEN_CLASS_NOT_FOUND(endpoints.get(0)));
    }
    if(!isImplClass){
        throw new BadCommandLineException(WscompileMessages.WSGEN_CLASS_MUST_BE_IMPLEMENTATION_CLASS(clazz.getName()));
    }
    endpoint = clazz;
    validateBinding();
}
 
Example #15
Source File: WebServiceVisitor.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
Example #16
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");
}
 
Example #17
Source File: JaxWsPortClientInterceptor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Initialize this client interceptor's properties from the given WebService annotation,
 * if necessary and possible (i.e. if "wsdlDocumentUrl", "namespaceUri", "serviceName"
 * and "portName" haven't been set but corresponding values are declared at the
 * annotation level of the specified service interface).
 * @param ann the WebService annotation found on the specified service interface
 */
protected void applyDefaultsFromAnnotation(WebService ann) {
	if (getWsdlDocumentUrl() == null) {
		String wsdl = ann.wsdlLocation();
		if (StringUtils.hasText(wsdl)) {
			try {
				setWsdlDocumentUrl(new URL(wsdl));
			}
			catch (MalformedURLException ex) {
				throw new IllegalStateException(
						"Encountered invalid @Service wsdlLocation value [" + wsdl + "]", ex);
			}
		}
	}
	if (getNamespaceUri() == null) {
		String ns = ann.targetNamespace();
		if (StringUtils.hasText(ns)) {
			setNamespaceUri(ns);
		}
	}
	if (getServiceName() == null) {
		String sn = ann.serviceName();
		if (StringUtils.hasText(sn)) {
			setServiceName(sn);
		}
	}
	if (getPortName() == null) {
		String pn = ann.portName();
		if (StringUtils.hasText(pn)) {
			setPortName(pn);
		}
	}
}
 
Example #18
Source File: CheckClasses.java    From tomee with Apache License 2.0 5 votes vote down vote up
private void check_hasInterface(final RemoteBean b) {
    if (b.getRemote() != null) {
        return;
    }
    if (b.getLocal() != null) {
        return;
    }

    Class<?> beanClass = null;
    try {
        beanClass = loadClass(b.getEjbClass());
    } catch (final OpenEJBException e) {
        // no-op
    }

    if (b instanceof EntityBean) {
        fail(b, "noInterfaceDeclared.entity", beanClass.getSimpleName());
        return;
    }

    if (b.getBusinessLocal().size() > 0) {
        return;
    }
    if (b.getBusinessRemote().size() > 0) {
        return;
    }

    if (((SessionBean) b).getServiceEndpoint() != null) {
        return;
    }

    if (beanClass.isAnnotationPresent(WebService.class)) {
        return;
    }

    //fail(b, "noInterfaceDeclared.session");
}
 
Example #19
Source File: JaxWsPortClientInterceptor.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize this client interceptor's properties from the given WebService annotation,
 * if necessary and possible (i.e. if "wsdlDocumentUrl", "namespaceUri", "serviceName"
 * and "portName" haven't been set but corresponding values are declared at the
 * annotation level of the specified service interface).
 * @param ann the WebService annotation found on the specified service interface
 */
protected void applyDefaultsFromAnnotation(WebService ann) {
	if (getWsdlDocumentUrl() == null) {
		String wsdl = ann.wsdlLocation();
		if (StringUtils.hasText(wsdl)) {
			try {
				setWsdlDocumentUrl(new URL(wsdl));
			}
			catch (MalformedURLException ex) {
				throw new IllegalStateException(
						"Encountered invalid @Service wsdlLocation value [" + wsdl + "]", ex);
			}
		}
	}
	if (getNamespaceUri() == null) {
		String ns = ann.targetNamespace();
		if (StringUtils.hasText(ns)) {
			setNamespaceUri(ns);
		}
	}
	if (getServiceName() == null) {
		String sn = ann.serviceName();
		if (StringUtils.hasText(sn)) {
			setServiceName(sn);
		}
	}
	if (getPortName() == null) {
		String pn = ann.portName();
		if (StringUtils.hasText(pn)) {
			setPortName(pn);
		}
	}
}
 
Example #20
Source File: ServiceFactory.java    From development with Apache License 2.0 5 votes vote down vote up
private <T> T getServicePort(Class<T> serviceClass)
        throws ParserConfigurationException {

    String targetNamespace = serviceClass.getAnnotation(WebService.class)
            .targetNamespace();
    QName serviceQName = new QName(targetNamespace,
            serviceClass.getSimpleName());
    Service service = createWebService(localWSDLUrl, serviceQName);
    service = addVersionInformation(service);
    return service.getPort(
            determineEndpointReference(serviceClass.getSimpleName()),
            serviceClass);
}
 
Example #21
Source File: WebServiceVisitor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
Example #22
Source File: HeidelpayResponseServlet.java    From development with Apache License 2.0 5 votes vote down vote up
String register(String wsdlUrl, RegistrationData registrationData,
        String wsUrl) throws ObjectNotFoundException, PaymentDataException,
        OperationNotPermittedException, MalformedURLException, Exception {
    PaymentRegistrationService paymentRegistrationServicePort = Service
            .create(new URL(wsdlUrl),
                    new QName(PaymentRegistrationService.class
                            .getAnnotation(WebService.class)
                            .targetNamespace(),
                            PaymentRegistrationService.class
                                    .getSimpleName())).getPort(
                    PaymentRegistrationService.class);
    setEndpointInContext(
            ((BindingProvider) paymentRegistrationServicePort), wsUrl);
    return paymentRegistrationServicePort.register(registrationData);
}
 
Example #23
Source File: WsgenOptions.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get an implementation class annotated with @WebService annotation.
 */
private void validateEndpointClass() throws BadCommandLineException {
    Class clazz = null;
    for(String cls : endpoints){
        clazz = getClass(cls);
        if (clazz == null)
            continue;

        if (clazz.isEnum() || clazz.isInterface() ||
            clazz.isPrimitive()) {
            continue;
        }
        isImplClass = true;
        WebService webService = (WebService) clazz.getAnnotation(WebService.class);
        if(webService == null)
            continue;
        break;
    }
    if(clazz == null){
        throw new BadCommandLineException(WscompileMessages.WSGEN_CLASS_NOT_FOUND(endpoints.get(0)));
    }
    if(!isImplClass){
        throw new BadCommandLineException(WscompileMessages.WSGEN_CLASS_MUST_BE_IMPLEMENTATION_CLASS(clazz.getName()));
    }
    endpoint = clazz;
    validateBinding();
}
 
Example #24
Source File: EndpointExporter.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private String makeAddress ( final ServiceReference<?> reference, final Object service, final WebService webService )
{
    String serviceName = webService.serviceName ();
    if ( serviceName == null )
    {
        if ( reference.getProperty ( Constants.SERVICE_PID ) != null )
        {
            serviceName = reference.getProperty ( Constants.SERVICE_PID ).toString ();
        }
    }

    return this.baseAddress + "/" + serviceName;
}
 
Example #25
Source File: JaxWsImplementorInfoTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWebServiceAnnotation() throws Exception {
    assertTrue(JaxWsImplementorInfo.
               ifAnnotationLoadedByOtherClassLoader(CalculatorImpl.class, WebService.class));
    assertFalse(JaxWsImplementorInfo.
                ifAnnotationLoadedByOtherClassLoader(CalculatorImpl.class, WebServiceProvider.class));

}
 
Example #26
Source File: WebServiceAp.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (context.getRound() != 1) {
        return true;
    }
    context.incrementRound();
    WebService webService;
    WebServiceProvider webServiceProvider;
    WebServiceVisitor webServiceVisitor = new WebServiceWrapperGenerator(this, context);
    boolean processedEndpoint = false;
    Collection<TypeElement> classes = new ArrayList<TypeElement>();
    filterClasses(classes, roundEnv.getRootElements());
    for (TypeElement element : classes) {
        webServiceProvider = element.getAnnotation(WebServiceProvider.class);
        webService = element.getAnnotation(WebService.class);
        if (webServiceProvider != null) {
            if (webService != null) {
                processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_AND_WEBSERVICEPROVIDER(element.getQualifiedName()));
            }
            processedEndpoint = true;
        }

        if (webService == null) {
            continue;
        }

        element.accept(webServiceVisitor, null);
        processedEndpoint = true;
    }
    if (!processedEndpoint) {
        if (isCommandLineInvocation) {
            if (!ignoreNoWebServiceFoundWarning) {
                processWarning(WebserviceapMessages.WEBSERVICEAP_NO_WEBSERVICE_ENDPOINT_FOUND());
            }
        } else {
            processError(WebserviceapMessages.WEBSERVICEAP_NO_WEBSERVICE_ENDPOINT_FOUND());
        }
    }
    return true;
}
 
Example #27
Source File: WebServiceVisitor.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
Example #28
Source File: AbstractJaxWsServiceExporter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Publish all {@link javax.jws.WebService} annotated beans in the
 * containing BeanFactory.
 * @see #publishEndpoint
 */
public void publishEndpoints() {
	Set<String> beanNames = new LinkedHashSet<String>(this.beanFactory.getBeanDefinitionCount());
	beanNames.addAll(Arrays.asList(this.beanFactory.getBeanDefinitionNames()));
	if (this.beanFactory instanceof ConfigurableBeanFactory) {
		beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames()));
	}
	for (String beanName : beanNames) {
		try {
			Class<?> type = this.beanFactory.getType(beanName);
			if (type != null && !type.isInterface()) {
				WebService wsAnnotation = type.getAnnotation(WebService.class);
				WebServiceProvider wsProviderAnnotation = type.getAnnotation(WebServiceProvider.class);
				if (wsAnnotation != null || wsProviderAnnotation != null) {
					Endpoint endpoint = createEndpoint(this.beanFactory.getBean(beanName));
					if (this.endpointProperties != null) {
						endpoint.setProperties(this.endpointProperties);
					}
					if (this.executor != null) {
						endpoint.setExecutor(this.executor);
					}
					if (wsAnnotation != null) {
						publishEndpoint(endpoint, wsAnnotation);
					}
					else {
						publishEndpoint(endpoint, wsProviderAnnotation);
					}
					this.publishedEndpoints.add(endpoint);
				}
			}
		}
		catch (CannotLoadBeanClassException ex) {
			// ignore beans where the class is not resolvable
		}
	}
}
 
Example #29
Source File: WebServiceVisitor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
Example #30
Source File: WebServiceVisitor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected void verifySeiAnnotations(WebService webService, TypeElement d) {
    if (webService.endpointInterface().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_ENDPOINTINTERFACE_ON_INTERFACE(
                d.getQualifiedName(), webService.endpointInterface()), d);
    }
    if (webService.serviceName().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT(
                "serviceName", d.getQualifiedName()), d);
    }
    if (webService.portName().length() > 0) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT(
                "portName", d.getQualifiedName()), d);
    }
}