本文整理匯總了Java中javax.jws.WebService.targetNamespace方法的典型用法代碼示例。如果您正苦於以下問題:Java WebService.targetNamespace方法的具體用法?Java WebService.targetNamespace怎麽用?Java WebService.targetNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jws.WebService
的用法示例。
在下文中一共展示了WebService.targetNamespace方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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);
}
}
}
示例4: preProcessWebService
import javax.jws.WebService; //導入方法依賴的package包/類
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);
}
}
示例5: createMapping
import javax.jws.WebService; //導入方法依賴的package包/類
private static Map<Class, QName> createMapping(Class... implementations) {
Map<Class, QName> result = new HashMap<>(implementations.length);
for (Class implementation : implementations) {
Deque<Class> toProcess = new ArrayDeque<>();
toProcess.add(implementation);
Class webServiceInterface = null;
do {
Class clazz = toProcess.poll();
if (clazz.getAnnotation(WebService.class) != null && clazz.isInterface()) {
webServiceInterface = clazz;
break;
}
if (clazz.getSuperclass() != null) {
toProcess.add(clazz.getSuperclass());
}
if (clazz.getInterfaces() != null) {
toProcess.addAll(Arrays.asList(clazz.getInterfaces()));
}
}
while (!toProcess.isEmpty());
if (webServiceInterface != null) {
WebService webService = (WebService)webServiceInterface.getAnnotation(WebService.class);
String targetNamespace = webService.targetNamespace();
if (targetNamespace.isEmpty()) {
targetNamespace = getDefaultTargetNamespace(implementation);
}
String serviceName = webService.serviceName();
if (serviceName.isEmpty()) {
serviceName = getDefaultServiceName(implementation);
}
result.put(webServiceInterface, new QName(targetNamespace, serviceName));
}
}
return result;
}
示例6: getService
import javax.jws.WebService; //導入方法依賴的package包/類
/**
* Creates an object implementing the service interface that needs to be called.
*
* @return the service object implementing the service interface
*/
public T getService() {
authorizationData.validate();
WebService webServiceAnnotation = serviceInterface.getAnnotation(WebService.class);
final String ns = webServiceAnnotation.targetNamespace();
final Map<String, String> headers = new HashMap<String, String>();
headers.put("CustomerAccountId", Long.toString(authorizationData.getAccountId()));
headers.put("CustomerId", Long.toString(authorizationData.getCustomerId()));
headers.put("DeveloperToken", authorizationData.getDeveloperToken());
refreshOAuthTokensIfNeeded();
this.authorizationData.getAuthentication().addHeaders(new HeadersImpl() {
@Override
public void addHeader(String name, String value) {
headers.put(name, value);
}
});
service.setHandlerResolver(new HandlerResolver() {
@Override
public List<Handler> getHandlerChain(PortInfo portInfo) {
List<Handler> handlerList = new ArrayList<Handler>();
handlerList.add(new HeaderHandler(ns, headers));
handlerList.add(MessageHandler.getInstance());
return handlerList;
}
});
T port = serviceFactory.createProxyFromService(service, environment, serviceInterface);
return port;
}
示例7: getServiceQname
import javax.jws.WebService; //導入方法依賴的package包/類
private QName getServiceQname(Class serviceInterface) {
WebService webServiceAnnotation = (WebService) serviceInterface.getAnnotation(WebService.class);
String serviceName = webServiceAnnotation.name();
if (serviceName.startsWith("I")) {
serviceName = serviceName.substring(1);
}
QName qName = new QName(webServiceAnnotation.targetNamespace(), serviceName);
return qName;
}
示例8: getServiceName
import javax.jws.WebService; //導入方法依賴的package包/類
/**
* gets the <code>wsdl:serviceName</code> for a given implementation class
* @param implClass the implementation class
* @return the <code>wsdl:serviceName</code> for the <code>implClass</code>
*/
public static QName getServiceName(Class<?> implClass) {
if (implClass.isInterface()) {
throw new RuntimeModelerException("runtime.modeler.cannot.get.serviceName.from.interface",
implClass.getCanonicalName());
}
String name = implClass.getSimpleName()+SERVICE;
String packageName = "";
if (implClass.getPackage() != null)
packageName = implClass.getPackage().getName();
WebService webService = implClass.getAnnotation(WebService.class);
if (webService == null) {
throw new RuntimeModelerException("runtime.modeler.no.webservice.annotation",
implClass.getCanonicalName());
}
if (webService.serviceName().length() > 0) {
name = webService.serviceName();
}
String targetNamespace = getNamespace(packageName);
if (webService.targetNamespace().length() > 0) {
targetNamespace = webService.targetNamespace();
} else if (targetNamespace == null) {
throw new RuntimeModelerException("runtime.modeler.no.package",
implClass.getName());
}
return new QName(targetNamespace, name);
}
示例9: getPortName
import javax.jws.WebService; //導入方法依賴的package包/類
/**
* gets the <code>wsdl:portName</code> for a given implementation class
* @param implClass the implementation class
* @param targetNamespace Namespace URI for service name
* @return the <code>wsdl:portName</code> for the <code>implClass</code>
*/
public static QName getPortName(Class<?> implClass, String targetNamespace) {
WebService webService = implClass.getAnnotation(WebService.class);
if (webService == null) {
throw new RuntimeModelerException("runtime.modeler.no.webservice.annotation",
implClass.getCanonicalName());
}
String name;
if (webService.portName().length() > 0) {
name = webService.portName();
} else if (webService.name().length() > 0) {
name = webService.name()+PORT;
} else {
name = implClass.getSimpleName()+PORT;
}
if (targetNamespace == null) {
if (webService.targetNamespace().length() > 0) {
targetNamespace = webService.targetNamespace();
} else {
String packageName = null;
if (implClass.getPackage() != null) {
packageName = implClass.getPackage().getName();
}
targetNamespace = getNamespace(packageName);
if (targetNamespace == null) {
throw new RuntimeModelerException("runtime.modeler.no.package",
implClass.getName());
}
}
}
return new QName(targetNamespace, name);
}
示例10: getPortType
import javax.jws.WebService; //導入方法依賴的package包/類
public static QName getPortType(final Class<?> seiClass) {
final WebService webService = seiClass.getAnnotation(WebService.class);
if (webService != null) {
String localName = webService.name();
if (localName == null || localName.length() == 0) {
localName = seiClass.getSimpleName();
}
final String namespace = webService.targetNamespace();
return new QName(getNamespace(seiClass, namespace), localName);
}
return null;
}
示例11: createDDEndpoint
import javax.jws.WebService; //導入方法依賴的package包/類
protected DDEndpoint createDDEndpoint(Class<?> sepClass, ArchiveDeployment dep, Endpoint ep)
{
WebService anWebService = sepClass.getAnnotation(WebService.class);
WebServiceProvider anWebServiceProvider = sepClass.getAnnotation(WebServiceProvider.class);
Class<?> seiClass = null;
String seiName;
String name = (anWebService != null) ? anWebService.name() : "";
if (name.length() == 0)
name = JavaUtils.getJustClassName(sepClass);
String serviceName = (anWebService != null) ? anWebService.serviceName() : anWebServiceProvider.serviceName();
if (serviceName.length() == 0) {
serviceName = JavaUtils.getJustClassName(sepClass) + "Service";
}
String serviceNS = (anWebService != null) ? anWebService.targetNamespace() : anWebServiceProvider.targetNamespace();
if (serviceNS.length() == 0)
serviceNS = getTypeNamespace(JavaUtils.getPackageName(sepClass));
String portName = (anWebService != null) ? anWebService.portName() : anWebServiceProvider.portName();
if (portName.length() == 0) {
portName = name + "Port";
}
String annWsdlLocation;
if (anWebService != null && anWebService.endpointInterface().length() > 0)
{
seiName = anWebService.endpointInterface();
ClassLoader runtimeClassLoader = dep.getClassLoader();
if(null == runtimeClassLoader)
throw MESSAGES.runtimeLoaderCannotBeNull(dep);
try
{
seiClass = runtimeClassLoader.loadClass(seiName);
}
catch (ClassNotFoundException cnfe)
{
throw new RuntimeException(cnfe);
}
WebService seiAnnotation = seiClass.getAnnotation(WebService.class);
if (seiAnnotation == null)
throw MESSAGES.webserviceAnnotationNotFound(seiName);
if (seiAnnotation.portName().length() > 0 || seiAnnotation.serviceName().length() > 0 || seiAnnotation.endpointInterface().length() > 0)
throw MESSAGES.webserviceAnnotationSEIAttributes(seiName);
annWsdlLocation = !"".equals(anWebService.wsdlLocation()) ? anWebService.wsdlLocation() : seiAnnotation.wsdlLocation();
}
else
{
annWsdlLocation = (anWebService != null) ? anWebService.wsdlLocation() : anWebServiceProvider.wsdlLocation();
}
DDEndpoint result = new DDEndpoint();
result.setId(ep.getShortName());
result.setAddress(SysPropUtils.expandSystemProperty(ep.getAddress()));
result.setImplementor(ep.getTargetBeanName());
result.setMtomEnabled(isMtomEnabled(ep.getTargetBeanClass()));
result.setEpClass(seiClass != null ? seiClass : sepClass);
result.setPortName(new QName(serviceNS, portName));
result.setServiceName(new QName(serviceNS, serviceName));
if (annWsdlLocation.length() > 0) {
result.setAnnotationWsdlLocation(annWsdlLocation);
}
return result;
}
示例12: getWebServiceAnnotation
import javax.jws.WebService; //導入方法依賴的package包/類
@Override
public WebServiceAnnotation getWebServiceAnnotation(Class<?> clazz) {
WebService annotation = clazz.getAnnotation(WebService.class);
return annotation == null ? null : new WebServiceAnnotation(annotation.targetNamespace(),
annotation.serviceName());
}
示例13: testCustomAnnotationSupport
import javax.jws.WebService; //導入方法依賴的package包/類
public void testCustomAnnotationSupport() {
JavaClassToDBCConverter converter = new JavaClassToDBCConverter(AnnotatedService.class);
HashMap<String, DescriptionBuilderComposite> dbcMap = converter.produceDBC();
DescriptionBuilderComposite dbc = dbcMap.get(AnnotatedService.class.getName());
assertNotNull(dbc);
SampleAnnotation sampleAnnotation = new SampleAnnotation();
sampleAnnotation.setAnnotationClassName(Custom.class.getName());
dbc.addCustomAnnotationInstance(sampleAnnotation);
SampleAnnotationProcessor saProcessor = new SampleAnnotationProcessor();
saProcessor.setAnnotationInstanceClassName(sampleAnnotation.getClass().getName());
dbc.addCustomAnnotationProcessor(saProcessor);
WebService webService = dbc.getWebServiceAnnot();
assertNotNull(webService);
String pn = webService.portName();
String tns = webService.targetNamespace();
assertNotNull(pn);
assertNotNull(tns);
QName portQName = new QName(tns, pn);
List<ServiceDescription> sdList = DescriptionFactoryImpl.createServiceDescriptionFromDBCMap(dbcMap, null);
assertNotNull(sdList);
assertEquals(sdList.size(), 1);
ServiceDescription sd = sdList.get(0);
assertNotNull(sd);
EndpointDescription ed = sd.getEndpointDescription(portQName);
assertNotNull(ed);
// for testing purposes we want to make a cast b/c some of the methods
// we are accessing are protected in EndpointDescriptionImpl
if(ed instanceof EndpointDescriptionImpl) {
EndpointDescriptionImpl edImpl = (EndpointDescriptionImpl) ed;
List<CustomAnnotationInstance> customAnnotationList = edImpl.getCustomAnnotationInstances();
assertNotNull(customAnnotationList);
assertEquals(customAnnotationList.size(), 1);
CustomAnnotationInstance annotationInstance = customAnnotationList.get(0);
assertNotNull(annotationInstance);
assertEquals(annotationInstance.getClass().getName(), SampleAnnotation.class.getName());
CustomAnnotationProcessor processor = edImpl.getCustomAnnotationProcessor(annotationInstance.getClass().getName());
assertNotNull(processor);
AxisService axisService = ed.getAxisService();
assertNotNull(axisService);
String name = (String) axisService.getParameterValue(SampleAnnotation.class.getName());
assertNotNull(name);
assertEquals(SampleAnnotationProcessor.class.getName(), name);
}
}
示例14: processClass
import javax.jws.WebService; //導入方法依賴的package包/類
void processClass(Class clazz) {
WebService webService = getPrivClassAnnotation(clazz, WebService.class);
String portTypeLocalName = clazz.getSimpleName();
if (webService.name().length() >0)
portTypeLocalName = webService.name();
targetNamespace = webService.targetNamespace();
packageName = "";
if (clazz.getPackage() != null)
packageName = clazz.getPackage().getName();
if (targetNamespace.length() == 0) {
targetNamespace = getNamespace(packageName);
}
model.setTargetNamespace(targetNamespace);
QName portTypeName = new QName(targetNamespace, portTypeLocalName);
model.setPortTypeName(portTypeName);
model.setWSDLLocation(webService.wsdlLocation());
SOAPBinding soapBinding = getPrivClassAnnotation(clazz, SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
soapBinding, clazz);
}
isWrapped = soapBinding.parameterStyle()== WRAPPED;
}
defaultBinding = createBinding(soapBinding);
/*
* if clazz != portClass then there is an SEI. If there is an
* SEI, then all methods should be processed. However, if there is
* no SEI, and the implementation class uses at least one
* WebMethod annotation, then only methods with this annotation
* will be processed.
*/
/* if (clazz == portClass) {
WebMethod webMethod;
for (Method method : clazz.getMethods()) {
webMethod = getPrivMethodAnnotation(method, WebMethod.class);
if (webMethod != null &&
!webMethod.exclude()) {
usesWebMethod = true;
break;
}
}
}*/
for (Method method : clazz.getMethods()) {
if (!clazz.isInterface()) { // if clazz is SEI, then all methods are web methods
if (!isWebMethodBySpec(method, clazz)) {
continue;
}
}
// TODO: binding can be null. We need to figure out how to post-process
// RuntimeModel to link to WSDLModel
processMethod(method);
}
//Add additional jaxb classes referenced by {@link XmlSeeAlso}
XmlSeeAlso xmlSeeAlso = getPrivClassAnnotation(clazz, XmlSeeAlso.class);
if(xmlSeeAlso != null)
model.addAdditionalClasses(xmlSeeAlso.value());
}