use of org.apache.cxf.message.MessageContentsList in project camel by apache.
the class DefaultCxfBinding method getResponsePayloadList.
// Non public methods
// -------------------------------------------------------------------------
protected MessageContentsList getResponsePayloadList(org.apache.cxf.message.Exchange exchange, List<Source> elements) {
BindingOperationInfo boi = exchange.getBindingOperationInfo();
if (boi.isUnwrapped()) {
boi = boi.getWrappedOperation();
exchange.put(BindingOperationInfo.class, boi);
}
MessageContentsList answer = new MessageContentsList();
int i = 0;
if (boi.getOutput() != null) {
for (MessagePartInfo partInfo : boi.getOutput().getMessageParts()) {
if (elements != null && elements.size() > i) {
answer.put(partInfo, elements.get(i++));
}
}
}
return answer;
}
use of org.apache.cxf.message.MessageContentsList in project camel by apache.
the class PersonProcessor method process.
@SuppressWarnings("unchecked")
public void process(Exchange exchange) throws Exception {
LOG.info("processing exchange in camel");
BindingOperationInfo boi = (BindingOperationInfo) exchange.getProperty(BindingOperationInfo.class.getName());
if (boi != null) {
LOG.info("boi.isUnwrapped" + boi.isUnwrapped());
}
// Get the parameters list which element is the holder.
MessageContentsList msgList = (MessageContentsList) exchange.getIn().getBody();
Holder<String> personId = (Holder<String>) msgList.get(0);
Holder<String> ssn = (Holder<String>) msgList.get(1);
Holder<String> name = (Holder<String>) msgList.get(2);
if (personId.value == null || personId.value.length() == 0) {
LOG.info("person id 123, so throwing exception");
// Try to throw out the soap fault message
org.apache.camel.wsdl_first.types.UnknownPersonFault personFault = new org.apache.camel.wsdl_first.types.UnknownPersonFault();
personFault.setPersonId("");
org.apache.camel.wsdl_first.UnknownPersonFault fault = new org.apache.camel.wsdl_first.UnknownPersonFault("Get the null value of person name", personFault);
// Since camel has its own exception handler framework, we can't throw the exception to trigger it
// We just set the fault message in the exchange for camel-cxf component handling and return
exchange.getOut().setFault(true);
exchange.getOut().setBody(fault);
return;
}
name.value = "Bonjour";
ssn.value = "123";
LOG.info("setting Bonjour as the response");
// Set the response message, first element is the return value of the operation,
// the others are the holders of method parameters
exchange.getOut().setBody(new Object[] { null, personId, ssn, name });
}
use of org.apache.cxf.message.MessageContentsList in project steve by RWTH-i5-IDSG.
the class FromAddressInterceptor method getChargeBoxId.
private String getChargeBoxId(Message message) {
MessageContentsList lst = MessageContentsList.getContentsList(message);
if (lst == null) {
return null;
}
MessageInfo mi = (MessageInfo) message.get("org.apache.cxf.service.model.MessageInfo");
for (MessagePartInfo mpi : mi.getMessageParts()) {
if (CHARGEBOX_ID_HEADER.equals(mpi.getName().getLocalPart())) {
return (String) lst.get(mpi);
}
}
return null;
}
use of org.apache.cxf.message.MessageContentsList in project ddf by codice.
the class BodyWriter method handleMessage.
@Override
public void handleMessage(Message outMessage) throws Fault {
MessageContentsList objs = MessageContentsList.getContentsList(outMessage);
if (objs == null || objs.size() == 0) {
return;
}
OutputStream os = outMessage.getContent(OutputStream.class);
if (os == null) {
XMLStreamWriter writer = outMessage.getContent(XMLStreamWriter.class);
if (writer == null) {
return;
}
}
Object body = objs.get(0);
Type t = outMessage.get(Type.class);
doWriteBody(outMessage, body, t);
}
use of org.apache.cxf.message.MessageContentsList in project tomee by apache.
the class CustomHandler method handleMessage.
@Override
public void handleMessage(final Message message) throws Fault {
if (isResponseAlreadyHandled(message)) {
return;
}
final MessageContentsList objs = MessageContentsList.getContentsList(message);
if (objs == null || objs.isEmpty()) {
return;
}
final Object responseObj = objs.get(0);
if (Response.class.isInstance(responseObj)) {
final Response response = Response.class.cast(responseObj);
if (is404(message, response)) {
switchResponse(message);
}
} else {
final Object exchangeStatus = message.getExchange().get(Message.RESPONSE_CODE);
final int status = exchangeStatus != null ? Integer.class.cast(exchangeStatus) : HttpsURLConnection.HTTP_OK;
if (status == HttpsURLConnection.HTTP_NOT_FOUND) {
switchResponse(message);
}
}
}
Aggregations