addAfter(RPCInInterceptor.class.getName());
addAfter(DocLiteralInInterceptor.class.getName());
}
public void handleMessage(Message m) throws Fault {
SoapMessage message = (SoapMessage) m;
SoapVersion soapVersion = message.getVersion();
Exchange exchange = message.getExchange();
MessageContentsList parameters = MessageContentsList.getContentsList(message);
if (null == parameters) {
parameters = new MessageContentsList();
}
BindingOperationInfo bop = exchange.getBindingOperationInfo();
if (null == bop) {
return;
}
if (bop.isUnwrapped()) {
bop = bop.getWrappedOperation();
}
boolean client = isRequestor(message);
BindingMessageInfo bmi = client ? bop.getOutput() : bop.getInput();
if (bmi == null) {
// one way operation.
return;
}
List<SoapHeaderInfo> headers = bmi.getExtensors(SoapHeaderInfo.class);
if (headers == null || headers.size() == 0) {
return;
}
boolean supportsNode = this.supportsDataReader(message, Node.class);
Service service = ServiceModelUtil.getService(message.getExchange());
for (SoapHeaderInfo header : headers) {
MessagePartInfo mpi = header.getPart();
try {
if (MessageUtils.getContextualBoolean(message,
org.apache.cxf.message.Message.SCHEMA_VALIDATION_ENABLED,
Boolean.FALSE)) {
Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0), message
.getExchange().getBus());
validateHeader(message, mpi, schema);
}
} catch (Fault f) {
if (!isRequestor(message)) {
f.setFaultCode(Fault.FAULT_CODE_CLIENT);
}
throw f;
}
if (mpi.getTypeClass() != null) {
Header param = findHeader(message, mpi);
Object object = null;
if (param != null) {
message.getHeaders().remove(param);
if (param.getDataBinding() == null) {
Node source = (Node)param.getObject();
if (source instanceof Element) {
//need to remove these attributes as they
//would cause validation failures
Element el = (Element)source;
el.removeAttributeNS(soapVersion.getNamespace(),
soapVersion.getAttrNameMustUnderstand());
el.removeAttributeNS(soapVersion.getNamespace(),
soapVersion.getAttrNameRole());
}
if (supportsNode) {
object = getNodeDataReader(message).read(mpi, source);
} else {
W3CDOMStreamReader reader = new W3CDOMStreamReader((Element)source);
try {
reader.nextTag(); //advance into the first tag
} catch (XMLStreamException e) {
//ignore
}
object = getDataReader(message, XMLStreamReader.class).read(mpi, reader);
}
} else {
object = param.getObject();
}
}
parameters.put(mpi, object);
}
}
if (parameters.size() > 0) {
message.setContent(List.class, parameters);
}
}