本文整理匯總了Java中javax.xml.soap.SOAPFactory.createFault方法的典型用法代碼示例。如果您正苦於以下問題:Java SOAPFactory.createFault方法的具體用法?Java SOAPFactory.createFault怎麽用?Java SOAPFactory.createFault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.soap.SOAPFactory
的用法示例。
在下文中一共展示了SOAPFactory.createFault方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: invoke
import javax.xml.soap.SOAPFactory; //導入方法依賴的package包/類
@Override
public DOMSource invoke(DOMSource request) {
try {
return invokeAllowingFaults(request);
} catch (FaultMessage faultMessage) {
try {
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault soapFault = factory.createFault();
soapFault.setFaultCode(SOAP11_FAULTCODE_SERVER); // todo here is a constant until we have a mechanism to determine the correct value (client / server)
soapFault.setFaultString(faultMessage.getMessage());
Detail detail = soapFault.addDetail();
serializeFaultMessage(detail, faultMessage);
// fault actor?
// stack trace of the outer exception (FaultMessage) is unimportant, because it is always created at one place
// todo consider providing stack trace of the inner exception
//Detail detail = soapFault.addDetail();
//detail.setTextContent(getStackTraceAsString(faultMessage));
throw new SOAPFaultException(soapFault);
} catch (SOAPException e) {
throw new RuntimeException("SOAP Exception: " + e.getMessage(), e);
}
}
}
示例2: createInvalidAddressingHeaderFault
import javax.xml.soap.SOAPFactory; //導入方法依賴的package包/類
public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) {
QName name = e.getProblemHeader();
QName subsubcode = e.getSubsubcode();
QName subcode = av.invalidMapTag;
String faultstring = String.format(av.getInvalidMapText(), name, subsubcode);
try {
SOAPFactory factory;
SOAPFault fault;
if (soapVer == SOAPVersion.SOAP_12) {
factory = SOAPVersion.SOAP_12.getSOAPFactory();
fault = factory.createFault();
fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
fault.appendFaultSubcode(subcode);
fault.appendFaultSubcode(subsubcode);
getInvalidMapDetail(name, fault.addDetail());
} else {
factory = SOAPVersion.SOAP_11.getSOAPFactory();
fault = factory.createFault();
fault.setFaultCode(subsubcode);
}
fault.setFaultString(faultstring);
return fault;
} catch (SOAPException se) {
throw new WebServiceException(se);
}
}
示例3: newMapRequiredFault
import javax.xml.soap.SOAPFactory; //導入方法依賴的package包/類
public SOAPFault newMapRequiredFault(MissingAddressingHeaderException e) {
QName subcode = addVer.mapRequiredTag;
QName subsubcode = addVer.mapRequiredTag;
String faultstring = addVer.getMapRequiredText();
try {
SOAPFactory factory;
SOAPFault fault;
if (soapVer == SOAPVersion.SOAP_12) {
factory = SOAPVersion.SOAP_12.getSOAPFactory();
fault = factory.createFault();
fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
fault.appendFaultSubcode(subcode);
fault.appendFaultSubcode(subsubcode);
getMapRequiredDetail(e.getMissingHeaderQName(), fault.addDetail());
} else {
factory = SOAPVersion.SOAP_11.getSOAPFactory();
fault = factory.createFault();
fault.setFaultCode(subsubcode);
}
fault.setFaultString(faultstring);
return fault;
} catch (SOAPException se) {
throw new WebServiceException(se);
}
}