本文整理匯總了Java中javax.xml.ws.WebFault.targetNamespace方法的典型用法代碼示例。如果您正苦於以下問題:Java WebFault.targetNamespace方法的具體用法?Java WebFault.targetNamespace怎麽用?Java WebFault.targetNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.ws.WebFault
的用法示例。
在下文中一共展示了WebFault.targetNamespace方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createFaultFromException
import javax.xml.ws.WebFault; //導入方法依賴的package包/類
/**
* Creates a SOAP fault from the exception and populates the message as well
* as the detail. The detail object is read from the method getFaultInfo of
* the throwable if present
*
* @param exception the cause exception
* @return SOAP fault from given Throwable
*/
@SuppressWarnings("unchecked")
private JAXBElement<Fault> createFaultFromException(final Throwable exception) {
WebFault webFault = exception.getClass().getAnnotation(WebFault.class);
if (webFault == null || webFault.targetNamespace() == null) {
throw new RuntimeException("The exception " + exception.getClass().getName()
+ " needs to have an WebFault annotation with name and targetNamespace", exception);
}
QName name = new QName(webFault.targetNamespace(), webFault.name());
Object faultObject;
try {
Method method = exception.getClass().getMethod("getFaultInfo");
faultObject = method.invoke(exception);
} catch (Exception e) {
throw new RuntimeCamelException("Exception while trying to get fault details", e);
}
Fault fault = new Fault();
fault.setFaultcode(FAULT_CODE_SERVER);
fault.setFaultstring(exception.getMessage());
Detail detailEl = new ObjectFactory().createDetail();
@SuppressWarnings("rawtypes")
JAXBElement<?> faultDetailContent = new JAXBElement(name, faultObject.getClass(), faultObject);
detailEl.getAny().add(faultDetailContent);
fault.setDetail(detailEl);
return new ObjectFactory().createFault(fault);
}
示例2: getTargetNamespace
import javax.xml.ws.WebFault; //導入方法依賴的package包/類
public String getTargetNamespace() {
if (targetNamespace.length() > 0) {
return targetNamespace;
} else {
// Load the annotation. The annotation may not be present in WSGen cases
WebFault annotation = this.getAnnoWebFault();
if (annotation != null &&
annotation.targetNamespace().length() > 0) {
targetNamespace = annotation.targetNamespace();
} else {
// The default is undefined
// The JAX-WS layer may use the fault bean information to determine the name
}
}
return targetNamespace;
}
示例3: createFaultFromException
import javax.xml.ws.WebFault; //導入方法依賴的package包/類
/**
* Creates a SOAP fault from the exception and populates the message as well
* as the detail. The detail object is read from the method getFaultInfo of
* the throwable if present
*
* @param exception the cause exception
* @return SOAP fault from given Throwable
*/
@SuppressWarnings("unchecked")
private JAXBElement<Fault> createFaultFromException(final Throwable exception) {
WebFault webFault = exception.getClass().getAnnotation(WebFault.class);
if (webFault == null || webFault.targetNamespace() == null) {
throw new RuntimeException("The exception " + exception.getClass().getName()
+ " needs to have an WebFault annotation with name and targetNamespace", exception);
}
QName name = new QName(webFault.targetNamespace(), webFault.name());
Object faultObject;
try {
Method method = exception.getClass().getMethod("getFaultInfo");
faultObject = method.invoke(exception);
} catch (Exception e) {
throw new RuntimeCamelException("Exception while trying to get fault details", e);
}
Fault fault = new Fault();
Faultcode code = new Faultcode();
code.setValue(FAULT_CODE_SERVER);
fault.setCode(code);
Reasontext text = new Reasontext();
text.setValue(exception.getMessage());
text.setLang("en");
fault.setReason(new Faultreason().withText(text));
Detail detailEl = new ObjectFactory().createDetail();
@SuppressWarnings("rawtypes")
JAXBElement<?> faultDetailContent = new JAXBElement(name, faultObject.getClass(), faultObject);
detailEl.getAny().add(faultDetailContent);
fault.setDetail(detailEl);
return new ObjectFactory().createFault(fault);
}
示例4: addExceptions
import javax.xml.ws.WebFault; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void addExceptions(Method method) {
Class<?>[] exTypes = method.getExceptionTypes();
for (Class<?> exType : exTypes) {
WebFault webFault = exType.getAnnotation(WebFault.class);
if (webFault != null) {
QName faultName = new QName(webFault.targetNamespace(), webFault.name());
faultNameToException.put(faultName, (Class<? extends Exception>) exType);
}
}
}
示例5: generateExceptionBean
import javax.xml.ws.WebFault; //導入方法依賴的package包/類
private boolean generateExceptionBean(TypeElement thrownDecl, String beanPackage) {
if (!builder.isServiceException(thrownDecl.asType()))
return false;
String exceptionName = ClassNameInfo.getName(thrownDecl.getQualifiedName().toString());
if (processedExceptions.contains(exceptionName))
return false;
processedExceptions.add(exceptionName);
WebFault webFault = thrownDecl.getAnnotation(WebFault.class);
String className = beanPackage+ exceptionName + BEAN.getValue();
Collection<MemberInfo> members = ap_generator.collectExceptionBeanMembers(thrownDecl);
boolean isWSDLException = isWSDLException(members, thrownDecl);
String namespace = typeNamespace;
String name = exceptionName;
FaultInfo faultInfo;
if (isWSDLException) {
TypeMirror beanType = getFaultInfoMember(members).getParamType();
faultInfo = new FaultInfo(TypeMonikerFactory.getTypeMoniker(beanType), true);
namespace = webFault.targetNamespace().length()>0 ?
webFault.targetNamespace() : namespace;
name = webFault.name().length()>0 ?
webFault.name() : name;
faultInfo.setElementName(new QName(namespace, name));
seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
return false;
}
if (webFault != null) {
namespace = webFault.targetNamespace().length()>0 ?
webFault.targetNamespace() : namespace;
name = webFault.name().length()>0 ?
webFault.name() : name;
className = webFault.faultBean().length()>0 ?
webFault.faultBean() : className;
}
JDefinedClass cls = getCMClass(className, CLASS);
faultInfo = new FaultInfo(className, false);
if (duplicateName(className)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE(
typeElement.getQualifiedName(), thrownDecl.getQualifiedName()));
}
boolean canOverWriteBean = builder.canOverWriteClass(className);
if (!canOverWriteBean) {
builder.log("Class " + className + " exists. Not overwriting.");
seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
return false;
}
if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null)
return false;
//write class comment - JAXWS warning
JDocComment comment = cls.javadoc();
for (String doc : GeneratorBase.getJAXWSClassComment(ToolVersion.VERSION.MAJOR_VERSION)) {
comment.add(doc);
}
// XmlElement Declarations
writeXmlElementDeclaration(cls, name, namespace);
// XmlType Declaration
//members = sortMembers(members);
XmlType xmlType = thrownDecl.getAnnotation(XmlType.class);
String xmlTypeName = (xmlType != null && !xmlType.name().equals("##default")) ? xmlType.name() : exceptionName;
String xmlTypeNamespace = (xmlType != null && !xmlType.namespace().equals("##default")) ? xmlType.namespace() : typeNamespace;
writeXmlTypeDeclaration(cls, xmlTypeName, xmlTypeNamespace, members);
writeMembers(cls, members);
seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
return true;
}
示例6: generateExceptionBean
import javax.xml.ws.WebFault; //導入方法依賴的package包/類
private boolean generateExceptionBean(TypeElement thrownDecl, String beanPackage) {
if (!builder.isServiceException(thrownDecl.asType()))
return false;
String exceptionName = ClassNameInfo.getName(thrownDecl.getQualifiedName().toString());
if (processedExceptions.contains(exceptionName))
return false;
processedExceptions.add(exceptionName);
WebFault webFault = thrownDecl.getAnnotation(WebFault.class);
String className = beanPackage+ exceptionName + BEAN.getValue();
Collection<MemberInfo> members = ap_generator.collectExceptionBeanMembers(thrownDecl);
boolean isWSDLException = isWSDLException(members, thrownDecl);
String namespace = typeNamespace;
String name = exceptionName;
FaultInfo faultInfo;
if (isWSDLException) {
TypeMirror beanType = getFaultInfoMember(members).getParamType();
faultInfo = new FaultInfo(TypeMonikerFactory.getTypeMoniker(beanType), true);
namespace = webFault.targetNamespace().length()>0 ?
webFault.targetNamespace() : namespace;
name = webFault.name().length()>0 ?
webFault.name() : name;
faultInfo.setElementName(new QName(namespace, name));
seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
return false;
}
if (webFault != null) {
namespace = webFault.targetNamespace().length()>0 ?
webFault.targetNamespace() : namespace;
name = webFault.name().length()>0 ?
webFault.name() : name;
className = webFault.faultBean().length()>0 ?
webFault.faultBean() : className;
}
JDefinedClass cls = getCMClass(className, CLASS);
faultInfo = new FaultInfo(className, false);
if (duplicateName(className)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE(
typeElement.getQualifiedName(), thrownDecl.getQualifiedName()));
}
boolean canOverWriteBean = builder.canOverWriteClass(className);
if (!canOverWriteBean) {
builder.log("Class " + className + " exists. Not overwriting.");
seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
return false;
}
if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null) {
return false;
}
addGeneratedFile(className);
//write class comment - JAXWS warning
JDocComment comment = cls.javadoc();
for (String doc : GeneratorBase.getJAXWSClassComment(ToolVersion.VERSION.MAJOR_VERSION)) {
comment.add(doc);
}
// XmlElement Declarations
writeXmlElementDeclaration(cls, name, namespace);
// XmlType Declaration
//members = sortMembers(members);
XmlType xmlType = thrownDecl.getAnnotation(XmlType.class);
String xmlTypeName = (xmlType != null && !xmlType.name().equals("##default")) ? xmlType.name() : exceptionName;
String xmlTypeNamespace = (xmlType != null && !xmlType.namespace().equals("##default")) ? xmlType.namespace() : typeNamespace;
writeXmlTypeDeclaration(cls, xmlTypeName, xmlTypeNamespace, members);
writeMembers(cls, members);
seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
return true;
}
示例7: generateExceptionBean
import javax.xml.ws.WebFault; //導入方法依賴的package包/類
private boolean generateExceptionBean(ClassDeclaration thrownDecl, String beanPackage) {
if (!builder.isServiceException(thrownDecl))
return false;
String exceptionName = ClassNameInfo.getName(thrownDecl.getQualifiedName());
if (processedExceptions.contains(exceptionName))
return false;
processedExceptions.add(exceptionName);
WebFault webFault = thrownDecl.getAnnotation(WebFault.class);
String className = beanPackage+ exceptionName + BEAN;
Collection<MemberInfo> members = APT_GENERATOR.collectExceptionBeanMembers(thrownDecl);
boolean isWSDLException = isWSDLException(members, thrownDecl);
String namespace = typeNamespace;
String name = exceptionName;
FaultInfo faultInfo;
if (isWSDLException) {
TypeMirror beanType = getFaultInfoMember(members).getParamType();
faultInfo = new FaultInfo(TypeMonikerFactory.getTypeMoniker(beanType), true);
namespace = webFault.targetNamespace().length()>0 ?
webFault.targetNamespace() : namespace;
name = webFault.name().length()>0 ?
webFault.name() : name;
faultInfo.setElementName(new QName(namespace, name));
seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
return false;
}
if (webFault != null) {
namespace = webFault.targetNamespace().length()>0 ?
webFault.targetNamespace() : namespace;
name = webFault.name().length()>0 ?
webFault.name() : name;
className = webFault.faultBean().length()>0 ?
webFault.faultBean() : className;
}
JDefinedClass cls = getCMClass(className, CLASS);
faultInfo = new FaultInfo(className, false);
if (duplicateName(className)) {
builder.onError(WebserviceapMessages.WEBSERVICEAP_METHOD_EXCEPTION_BEAN_NAME_NOT_UNIQUE(typeDecl.getQualifiedName(), thrownDecl.getQualifiedName()));
}
boolean canOverWriteBean = builder.canOverWriteClass(className);
if (!canOverWriteBean) {
builder.log("Class " + className + " exists. Not overwriting.");
seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
return false;
}
if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null)
return false;
//write class comment - JAXWS warning
JDocComment comment = cls.javadoc();
for (String doc : GeneratorBase.getJAXWSClassComment(builder.getSourceVersion())) {
comment.add(doc);
}
// XmlElement Declarations
writeXmlElementDeclaration(cls, name, namespace);
// XmlType Declaration
//members = sortMembers(members);
XmlType xmlType = thrownDecl.getAnnotation(XmlType.class);
String xmlTypeName = (xmlType != null && !xmlType.name().equals("##default")) ? xmlType.name() : exceptionName;
String xmlTypeNamespace = (xmlType != null && !xmlType.namespace().equals("##default")) ? xmlType.namespace() : typeNamespace;
writeXmlTypeDeclaration(cls, xmlTypeName, xmlTypeNamespace, members);
writeMembers(cls, members);
seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
return true;
}