ppalaga commented on code in PR #4264:
URL: https://github.com/apache/camel-quarkus/pull/4264#discussion_r1016661885


##########
integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomResource.java:
##########
@@ -56,22 +74,30 @@ public Response upload(@QueryParam("imageName") String 
imageName, @QueryParam("m
 
     @Path("/download")
     @POST
+    @Produces(MediaType.APPLICATION_OCTET_STREAM)
     @Consumes(MediaType.TEXT_PLAIN)
-    public Response download(@QueryParam("imageName") String imageName, 
@QueryParam("mtomEnabled") boolean mtomEnabled)
+    public Response download(@QueryParam("imageName") String imageName, 
@QueryParam("mtomEnabled") boolean mtomEnabled,
+            @QueryParam("endpointDataFormat") String endpointDataFormat)
             throws Exception {
-        final ImageFile response = (ImageFile) 
producerTemplate.requestBodyAndHeader(
-                "direct:" + mtomEndpoint(mtomEnabled),
-                imageName,
-                OPERATION_NAME,
-                "downloadImage", ImageFile.class);
+        Map<String, Object> headers = new LinkedHashMap<>();
+        headers.put(OPERATION_NAME, "downloadImage");
+        headers.put("endpointDataFormat", endpointDataFormat);
+        headers.put("mtomEnabled", mtomEnabled);
+        Exchange result = producerTemplate.request("direct:invoker", exchange 
-> {
+            exchange.setPattern(ExchangePattern.InOut);
+            exchange.getIn().setBody(imageName);
+            exchange.getIn().setHeaders(headers);
+        });
+        Object response = null;
+        if ("PAYLOAD".equals(endpointDataFormat)) {
+            response = 
result.getMessage(AttachmentMessage.class).getAttachment(imageName).getContent();
+        } else {
+            response = 
result.getMessage().getBody(ImageFile.class).getContent();
+        }

Review Comment:
   I wonder whether we should make our assumption about the runtime type of 
`getAttachment(imageName).getContent()` explicit? In that way all future 
readers will clearly see what is sent back over the wire.
   
   Something like 
   
   ```suggestion
           final byte[] response = null;
           if ("PAYLOAD".equals(endpointDataFormat)) {
               response = (byte[]) 
result.getMessage(AttachmentMessage.class).getAttachment(imageName).getContent();
           } else {
               response = 
result.getMessage().getBody(ImageFile.class).getContent();
           }
   ```



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