本文整理汇总了Java中org.xmlsoap.schemas.soap.envelope.Fault类的典型用法代码示例。如果您正苦于以下问题:Java Fault类的具体用法?Java Fault怎么用?Java Fault使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Fault类属于org.xmlsoap.schemas.soap.envelope包,在下文中一共展示了Fault类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFaultFromException
import org.xmlsoap.schemas.soap.envelope.Fault; //导入依赖的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: doUnmarshal
import org.xmlsoap.schemas.soap.envelope.Fault; //导入依赖的package包/类
@Override
public Object doUnmarshal(Exchange exchange, InputStream stream, Object rootObject) throws IOException {
if (rootObject.getClass() != Envelope.class) {
throw new RuntimeCamelException("Expected Soap Envelope but got " + rootObject.getClass());
}
Envelope envelope = (Envelope) rootObject;
Header header = envelope.getHeader();
if (header != null) {
List<Object> returnHeaders;
List<Object> anyHeaderElements = envelope.getHeader().getAny();
if (null != anyHeaderElements && !(getDataFormat().isIgnoreUnmarshalledHeaders())) {
if (getDataFormat().isIgnoreJAXBElement()) {
returnHeaders = new ArrayList<Object>();
for (Object headerEl : anyHeaderElements) {
returnHeaders.add(JAXBIntrospector.getValue(headerEl));
}
} else {
returnHeaders = anyHeaderElements;
}
exchange.getOut().setHeader(SoapJaxbDataFormat.SOAP_UNMARSHALLED_HEADER_LIST, returnHeaders);
}
}
List<Object> anyElement = envelope.getBody().getAny();
if (anyElement.size() == 0) {
// No parameter so return null
return null;
}
Object payloadEl = anyElement.get(0);
Object payload = JAXBIntrospector.getValue(payloadEl);
if (payload instanceof Fault) {
Exception exception = createExceptionFromFault((Fault) payload);
exchange.setException(exception);
return null;
} else {
return getDataFormat().isIgnoreJAXBElement() ? payload : payloadEl;
}
}
示例3: getFault
import org.xmlsoap.schemas.soap.envelope.Fault; //导入依赖的package包/类
/**
* Ruft den Wert der fault-Eigenschaft ab.
*
* @return possible object is {@link Fault }
*
*/
public Fault getFault() {
return fault;
}
示例4: setFault
import org.xmlsoap.schemas.soap.envelope.Fault; //导入依赖的package包/类
/**
* Legt den Wert der fault-Eigenschaft fest.
*
* @param value
* allowed object is {@link Fault }
*
*/
public void setFault(Fault value) {
this.fault = value;
}