gnodet-bot commented on code in PR #30232:
URL: https://github.com/apache/camel/pull/30232#discussion_r4591250184


##########
components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfProducer.java:
##########
@@ -439,16 +462,46 @@ private BindingOperationInfo 
getBindingOperationInfo(Exchange ex) {
 
             LOG.trace("Operation qname = {}", qname);
 
-            answer = 
client.getEndpoint().getEndpointInfo().getBinding().getOperation(qname);
+            answer = binding.getOperation(qname);
             if (answer == null) {
                 throw new IllegalArgumentException(
                         "Can't find the BindingOperationInfo with operation 
name " + qname
-                                                   + ". Please check the 
message headers of operationName and operationNamespace.");
+                                                   + ". Please check the " + 
CxfConstants.OPERATION_NAME + " and "
+                                                   + 
CxfConstants.OPERATION_NAMESPACE
+                                                   + " headers, or the 
defaultOperationName and defaultOperationNamespace"
+                                                   + " options. The operations 
of the service are "
+                                                   + operationNames(binding));
             }
         }
         return answer;
     }
 
+    private void warnOnFormerOperationHeaders(Exchange ex) {
+        if (formerOperationHeadersWarned) {
+            return;
+        }
+        String former = null;
+        if (ex.getIn().getHeader(CxfConstants.OPERATION_NAME) == null
+                && ex.getIn().getHeader(FORMER_OPERATION_NAME) != null) {
+            former = FORMER_OPERATION_NAME;
+        } else if (ex.getIn().getHeader(CxfConstants.OPERATION_NAMESPACE) == 
null
+                && ex.getIn().getHeader(FORMER_OPERATION_NAMESPACE) != null) {
+            former = FORMER_OPERATION_NAMESPACE;
+        }
+        if (former != null) {
+            formerOperationHeadersWarned = true;
+            LOG.warn("The producer of endpoint {} does not read the {} header: 
the operation is selected by the {} and {}"
+                     + " headers (CxfConstants.OPERATION_NAME and 
CxfConstants.OPERATION_NAMESPACE), which replaced the {}"
+                     + " and {} headers. This is logged once.",
+                    endpoint, former, CxfConstants.OPERATION_NAME, 
CxfConstants.OPERATION_NAMESPACE, FORMER_OPERATION_NAME,
+                    FORMER_OPERATION_NAMESPACE);
+        }
+    }

Review Comment:
   Single shared flag suppresses the operationNamespace warning.
   
   This `else-if` with a shared `formerOperationHeadersWarned` flag has two 
problems:
   1. When *both* old names are set without their replacements, only 
`operationName` is mentioned as not read -- `operationNamespace` is silently 
skipped by the else-if.
   2. Once the flag is set for `operationName`, if the user fixes that (adds 
`CamelCxfOperationName`) but keeps the old `operationNamespace`, subsequent 
exchanges hit the early return and the namespace mismatch is never warned about.
   
   See review body for suggested rewrite using two independent flags.



-- 
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]

Reply via email to