[ 
https://issues.apache.org/jira/browse/CAMEL-26143?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Work on CAMEL-26143 started by Claus Ibsen.
-------------------------------------------
> camel-cxf - a byte[] reply in POJO mode is a ClassCastException fault, and 
> the POJO producer splits a String body into several parameters
> -----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26143
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26143
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-cxf
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Major
>             Fix For: 4.24.0
>
>
> Found while adding the catalog body types of cxf (SOAP) (CAMEL-24961, PR 
> #28395).
> h4. 1. A byte[] reply in POJO (and CXF_MESSAGE) mode is a SOAP fault 
> ClassCastException
> {{DefaultCxfBinding.populateOutBody}} (main 2a465aa4814c, lines 599-600) 
> checks {{outBody.getClass().isArray()}} and casts to {{Object[]}}, which 
> fails for a primitive array: a {{byte[]}} reply gives the SOAP fault "class 
> [B cannot be cast to class [Ljava.lang.Object". Checked on 4.24.0-SNAPSHOT 
> with a cxf consumer in POJO and CXF_MESSAGE mode.
> Proposed: only cast {{Object[]}} ({{outBody instanceof Object[]}}) and wrap 
> any other value, a {{byte[]}} included, as one element.
> h4. 2. The POJO producer splits a non-List body into parameters
> {{CxfProducer.getParams}} (line 367) turns a body that is not a List or an 
> array into parameters with {{getBody(Iterator.class)}}, so a String 
> {{"Hello,World"}} becomes 2 parameters and a {{byte[]}} N parameters (one per 
> byte), and the call fails or goes to the wrong arguments. Checked on 
> 4.24.0-SNAPSHOT with the cxf producer in POJO mode.
> Proposed: use a single non-collection body (String, byte[], Number, POJO) as 
> the one parameter, and iterate only collections.
> h4. 3. CXF_MESSAGE sends an empty envelope for a String, byte[], stream or 
> Document
> In CXF_MESSAGE mode {{CxfProducer.getParams}} (line 391) passes the body as 
> it is, and the reply side {{DefaultCxfBinding.getBodyFromCamel}} (line 1211) 
> does the same; a body that is not a {{SOAPMessage}} (a String, byte[], stream 
> or Document of the envelope) ends as an empty SOAP envelope, with no error. 
> Checked on 4.24.0-SNAPSHOT with the cxf producer and consumer in CXF_MESSAGE 
> mode.
> Proposed: convert the body to {{SOAPMessage}} (failing when it cannot be 
> converted) on both sides.
> h4. 4. PAYLOAD and RAW replies that do not convert give an empty response
> {{DefaultCxfBinding.getBodyFromCamel}} (lines 1206-1209) uses the 
> non-mandatory {{getBody(CxfPayload.class)}} and 
> {{getBody(InputStream.class)}}; for a Map (or a null body) the result is null 
> and {{populateCxfResponseFromExchange}} (line 537) sets nothing, so PAYLOAD 
> replies with an empty {{soap:Body}} and RAW with an empty response, no fault. 
> Checked on 4.24.0-SNAPSHOT with a cxf consumer in PAYLOAD and RAW mode.
> Proposed: fail (SOAP fault) when a non-null reply body cannot be converted to 
> the data format's type.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to