17.15. Camel에서 iPXE Fault를 던질 수 있는 방법
CHAP 요청을 소비하기 위해 camel-cxf 끝점을 사용하는 경우 camel 컨텍스트에서 CloudEvent Fault를 throw해야 할 수 있습니다.
기본적으로 throwFault DSL을 사용하여 이 작업을 수행할 수 있습니다. 해당 DSL을 사용할 수 있습니다. 해당 DSL은#177 ,PAYLOAD 및 MESSAGE 데이터 형식에 적합합니다.
CxfCustomizedExceptionTest 에 표시된대로 soap 오류를 정의할 수 있습니다.
SOAP_FAULT = new SoapFault(EXCEPTION_MESSAGE, SoapFault.FAULT_CODE_CLIENT);
Element detail = SOAP_FAULT.getOrCreateDetail();
Document doc = detail.getOwnerDocument();
Text tn = doc.createTextNode(DETAIL_TEXT);
detail.appendChild(tn);
원하는 대로 던질 수 있습니다.
from(routerEndpointURI).setFaultBody(constant(SOAP_FAULT));
CXF 끝점이 MESSAGE 데이터 형식으로 작업하는 경우 메시지 본문에서 iPXE Fault 메시지를 설정하고 CxfMessageStreamException에서 시연한 대로 메시지 헤더에서 응답 코드를 설정할 수 있습니다.
from(routerEndpointURI).process(new Processor() {
public void process(Exchange exchange) throws Exception {
Message out = exchange.getOut();
// Set the message body with the
out.setBody(this.getClass().getResourceAsStream("SoapFaultMessage.xml"));
// Set the response code here
out.setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500));
}
});
CloudEvent 데이터 형식을 사용하는 것과 동일합니다. lossfault는 본문에서 설정할 수 있습니다.