faultActor = rex.getFaultActor(); // SOAP Fault faultActor
DispositionReport dispRpt = rex.getDispositionReport();
if (dispRpt != null)
{
Result result = null;
ErrInfo errInfo = null;
Vector results = dispRpt.getResultVector();
if ((results != null) && (!results.isEmpty()))
result = (Result)results.elementAt(0);
if (result != null)
{
errno = String.valueOf(result.getErrno()); // UDDI Result errno
errInfo = result.getErrInfo();
if (errInfo != null)
{
errCode = errInfo.getErrCode(); // UDDI ErrInfo errCode
errText = errInfo.getErrMsg(); // UDDI ErrInfo errMsg
}
}
}
}
else if (ex instanceof SOAPException)
{
log.error(ex.getMessage());
// Because something occured that jUDDI wasn't expecting
// let's set default SOAP Fault values. Since SOAPExceptions
// here are most likely XML validation errors let's blame the
// client by placing "Client" in the Fault Code and pass
// the Exception message back to the client.
faultCode = "Client";
faultString = ex.getMessage();
faultActor = null;
// Let's set default values for the UDDI DispositionReport
// here. While we didn't catch a RegistryException (or
// subclass) we're going to be friendly and include a
// FatalError DispositionReport within the message from the
// SAX parsing problem in the SOAP Fault anyway.
errno = String.valueOf(Result.E_FATAL_ERROR);
errCode = Result.lookupErrCode(Result.E_FATAL_ERROR);
errText = Result.lookupErrText(Result.E_FATAL_ERROR) +
" " + ex.getMessage();
}
else // anything else
{
// All other exceptions (other than SOAPException or
// RegistryException and subclasses) are either a result
// of a jUDDI configuration problem or something that
// we *should* be catching and converting to a
// RegistryException but are not (yet!).
log.error(ex.getMessage(),ex);
// Because something occured that jUDDI wasn't expecting
// let's set default SOAP Fault values. Since jUDDI
// should be catching anything significant let's blame
// jUDDI by placing "Server" in the Fault Code and pass
// the Exception message on to the client.
faultCode = "Server";
faultString = ex.getMessage();
faultActor = null;
// Let's set default values for the UDDI DispositionReport
// here. While we didn't catch a RegistryException (or
// subclass) but we're going to be friendly and include a
// FatalError DispositionReport within the SOAP Fault anyway.
errno = String.valueOf(Result.E_FATAL_ERROR);
errCode = Result.lookupErrCode(Result.E_FATAL_ERROR);
errText = Result.lookupErrText(Result.E_FATAL_ERROR) +
" An internal UDDI server error has " +
"occurred. Please report this error " +
"to the UDDI server administrator.";
}
// We should have everything we need to assemble
// the SOAPFault so lets piece it together and
// send it on it's way.
try {
SOAPBody soapResBody = soapRes.getSOAPBody();
SOAPFault soapFault = soapResBody.addFault();
soapFault.setFaultCode(faultCode);
soapFault.setFaultString(faultString);
soapFault.setFaultActor(faultActor);
// We're always going to include a DispositionReport (for
// the hell of it) so that's what we're doing here.
Detail faultDetail = soapFault.addDetail();
SOAPElement dispRpt = faultDetail.addChildElement("dispositionReport","",IRegistry.UDDI_V2_NAMESPACE);
dispRpt.setAttribute("generic",IRegistry.UDDI_V2_GENERIC);
dispRpt.setAttribute("operator",Config.getOperator());
SOAPElement result = dispRpt.addChildElement("result");
result.setAttribute("errno",errno);
SOAPElement errInfo = result.addChildElement("errInfo");
errInfo.setAttribute("errCode",errCode);
errInfo.setValue(errText);
}
catch (Exception e) { // if we end up in here it's just NOT good.
log.error("A serious error has occured while assembling the SOAP Fault.",e);