本文整理匯總了Java中javax.jws.WebService類的典型用法代碼示例。如果您正苦於以下問題:Java WebService類的具體用法?Java WebService怎麽用?Java WebService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WebService類屬於javax.jws包,在下文中一共展示了WebService類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: prepare
import javax.jws.WebService; //導入依賴的package包/類
/**
* 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;
}
示例2: shouldProcessMethod
import javax.jws.WebService; //導入依賴的package包/類
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;
}
示例3: attachWebServiceAnnotation
import javax.jws.WebService; //導入依賴的package包/類
/**
* This method will be used to attach @WebService annotation data to the
* <code>DescriptionBuildercomposite</code>
*
* @param composite - <code>DescriptionBuilderComposite</code>
*/
private void attachWebServiceAnnotation(DescriptionBuilderComposite composite) {
WebService webService = (WebService)ConverterUtils.getAnnotation(
WebService.class, serviceClass);
if (webService != null) {
// Attach @WebService annotated data
WebServiceAnnot wsAnnot = WebServiceAnnot.createWebServiceAnnotImpl();
wsAnnot.setEndpointInterface(webService.endpointInterface());
// check for SEI and save name if necessary
seiClassName = webService.endpointInterface();
wsAnnot.setName(webService.name());
wsAnnot.setPortName(webService.portName());
wsAnnot.setServiceName(webService.serviceName());
wsAnnot.setTargetNamespace(webService.targetNamespace());
wsAnnot.setWsdlLocation(webService.wsdlLocation());
composite.setWebServiceAnnot(wsAnnot);
}
}
示例4: postProcessAfterInitialization
import javax.jws.WebService; //導入依賴的package包/類
@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;
}
示例5: verifyImplementorClass
import javax.jws.WebService; //導入依賴的package包/類
/**
* Verifies if the endpoint implementor class has @WebService or @WebServiceProvider
* annotation
*
* @return
* true if it is a Provider or AsyncProvider endpoint
* false otherwise
* @throws java.lang.IllegalArgumentException
* If it doesn't have any one of @WebService or @WebServiceProvider
* If it has both @WebService and @WebServiceProvider annotations
*/
public static boolean verifyImplementorClass(Class<?> clz) {
WebServiceProvider wsProvider = clz.getAnnotation(WebServiceProvider.class);
WebService ws = clz.getAnnotation(WebService.class);
if (wsProvider == null && ws == null) {
throw new IllegalArgumentException(clz +" has neither @WebService nor @WebServiceProvider annotation");
}
if (wsProvider != null && ws != null) {
throw new IllegalArgumentException(clz +" has both @WebService and @WebServiceProvider annotations");
}
if (wsProvider != null) {
if (Provider.class.isAssignableFrom(clz) || AsyncProvider.class.isAssignableFrom(clz)) {
return true;
}
throw new IllegalArgumentException(clz +" doesn't implement Provider or AsyncProvider interface");
}
return false;
}
示例6: getPort
import javax.jws.WebService; //導入依賴的package包/類
@Override
public <T> T getPort(final Class<T> serviceEndpointInterface) {
final T t = serviceDelegate.getPort(serviceEndpointInterface);
QName qname = null;
if (serviceEndpointInterface.isAnnotationPresent(WebService.class)) {
final WebService webService = serviceEndpointInterface.getAnnotation(WebService.class);
final String targetNamespace = webService.targetNamespace();
final String name = webService.name();
if (targetNamespace != null && targetNamespace.length() > 0 && name != null && name.length() > 0) {
qname = new QName(targetNamespace, name);
}
}
setProperties((BindingProvider) t, qname);
return t;
}
示例7: findIncorrectAnnotationAndWarn
import javax.jws.WebService; //導入依賴的package包/類
private void findIncorrectAnnotationAndWarn(final IAnnotationFinder finder, final String component) {
final List<Class<?>> webserviceAnnotatedClasses = finder.findAnnotatedClasses(WebService.class);
for (final Class clazz : webserviceAnnotatedClasses) {
final Annotation[] annotations = clazz.getDeclaredAnnotations();
final List<Annotation> declaredAnnotations = Arrays.asList(annotations);
for (final Annotation declaredAnn : declaredAnnotations) {
if (declaredAnn.annotationType().getName().equals("javax.ejb.Stateful")) {
warn(component, "annotation.invalid.stateful.webservice", clazz.getName());
}
if (declaredAnn.annotationType().getName().equals("javax.annotation.ManagedBean")) {
warn(component, "annotation.invalid.managedbean.webservice", clazz.getName());
}
if (declaredAnn.annotationType().getName().equals("javax.ejb.MessageDriven")) {
warn(component, "annotation.invalid.messagedriven.webservice", clazz.getName());
}
}
}
}
示例8: getPort
import javax.jws.WebService; //導入依賴的package包/類
public <T> T getPort(final Class<T> serviceEndpointInterface) {
final T t = serviceDelegate.getPort(serviceEndpointInterface);
QName qname = null;
if (serviceEndpointInterface.isAnnotationPresent(WebService.class)) {
final WebService webService = serviceEndpointInterface.getAnnotation(WebService.class);
final String targetNamespace = webService.targetNamespace();
final String name = webService.name();
if (targetNamespace != null && targetNamespace.length() > 0 && name != null && name.length() > 0) {
qname = new QName(targetNamespace, name);
}
}
setProperties((BindingProvider) t, qname);
return customizePort(t);
}
示例9: getName
import javax.jws.WebService; //導入依賴的package包/類
public static String getName(final Class<?> clazz) {
final WebService webService = clazz.getAnnotation(WebService.class);
if (webService != null) {
final String sei = webService.endpointInterface();
if (sei != null && sei.trim().length() != 0) {
try {
final Class seiClass = clazz.getClassLoader().loadClass(sei.trim());
return getNameFromInterface(seiClass);
} catch (final ClassNotFoundException e) {
throw new OpenEJBRuntimeException("Unable to load SEI class: " + sei, e);
}
}
return getName(clazz, webService.name());
}
final WebServiceProvider webServiceProvider = clazz.getAnnotation(WebServiceProvider.class);
if (webServiceProvider != null) {
return clazz.getName();
}
throw new IllegalArgumentException("The " + clazz.getName() + " is not annotated");
}
示例10: getServicePort
import javax.jws.WebService; //導入依賴的package包/類
<T> T getServicePort(Class<T> serviceClass, Map<String, Setting> settings)
throws MalformedURLException {
String targetNamespace = serviceClass.getAnnotation(WebService.class)
.targetNamespace();
QName serviceQName = new QName(targetNamespace,
serviceClass.getSimpleName());
Service service = createWebService(getWsdlUrl(serviceClass, settings),
serviceQName);
// addVersionInformation(service);
return service.getPort(serviceClass);
}
示例11: makeAddress
import javax.jws.WebService; //導入依賴的package包/類
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;
}
示例12: register
import javax.jws.WebService; //導入依賴的package包/類
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);
}
示例13: getServicePort
import javax.jws.WebService; //導入依賴的package包/類
<T> T getServicePort(Class<T> serviceClass, Map<String, Setting> settings)
throws MalformedURLException {
String targetNamespace = serviceClass.getAnnotation(WebService.class)
.targetNamespace();
QName serviceQName = new QName(targetNamespace,
serviceClass.getSimpleName());
Service service = createWebService(getWsdlUrl(serviceClass, settings),
serviceQName);
addVersionInformation(service);
return service.getPort(serviceClass);
}
示例14: getServicePort
import javax.jws.WebService; //導入依賴的package包/類
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);
}
示例15: applyDefaultsFromAnnotation
import javax.jws.WebService; //導入依賴的package包/類
/**
* 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);
}
}
}