reta commented on a change in pull request #839:
URL: https://github.com/apache/cxf/pull/839#discussion_r698031709
##########
File path:
rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java
##########
@@ -107,20 +107,12 @@ public void handleMessage(Message m) throws Fault {
boolean supportsNode = this.supportsDataReader(message, Node.class);
Service service = ServiceModelUtil.getService(message.getExchange());
+
+ validateHeaders(message, headers, service);
+
for (SoapHeaderInfo header : headers) {
MessagePartInfo mpi = header.getPart();
- try {
- if
(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message)) {
Review comment:
I agree with you that removing schema and validation flag check out of
the loop does make sense, but you still have to go over each header and now we
have to do this twice (in the loop and `validateHeaders`).
I would suggest a bit different change:
```
Schema schema = null;
final boolean schemaValidationEnabled =
ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message);
if (schemaValidationEnabled) {
schema =
EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0),
message.getExchange().getBus());
}
for (SoapHeaderInfo header : headers) {
MessagePartInfo mpi = header.getPart();
try {
if (schemaValidationEnabled && schema != null) {
validateHeader(message, mpi, schema);
}
} catch (Fault f) {
if (!isRequestor(message)) {
f.setFaultCode(Fault.FAULT_CODE_CLIENT);
}
throw f;
}
...
}
```
WDYT? Thank you.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]