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

Stephan Siano updated CAMEL-8663:
---------------------------------
    Attachment: 0001-Extension-to-Aki-s-patch.patch

Hi Aki,

I have added some extensions to your patch. It contains the following changes:
1. I removed unused import statements left behind by your refactoring
2. I made the DelegatingXMLStream reader less aggressive. The namespaces are 
only injected on the top element that is read, not on every element of the 
payload.
3. The CachedCxfPayload will wrap the XMLStreamReader only into a 
DelegatingXMLStreamReader if it is not already one (the type converter normally 
already does this wrapping). The following identity transformation is done 
directly into a StreamResult backed by a CachedOutputStream. This avoids the 
type conversion into a StreamSource which is backed by a String that is then 
copied into a CachedOutputStream in the constructor of the StreamSourceCache.
4. I added two addiontional tests that also test this kind of messages with 
stream caching.
5. I think the org.apache.cxf.binding.soap.addNamespaceContext should always be 
set to true for Camel-CXF endpoints in payload mode. It is very intransparent 
to the user whether this setting is reqired or not, so I think it should always 
be enabled to be on the safe side.

What do you think?

Best regards
Stephan

> Namespaces defined on the SOAP envelope get lost in PAYLOAD mode
> ----------------------------------------------------------------
>
>                 Key: CAMEL-8663
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8663
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-cxf
>            Reporter: Stephan Siano
>            Assignee: Akitoshi Yoshida
>         Attachments: 
> 0001-CAMEL-8663-Namespaces-defined-on-SOAP-envelope-lost-.patch, 
> 0001-Extension-to-Aki-s-patch.patch
>
>
> If a request message is send to a CXF consumer or a response is returned to 
> the CXF provider that contains namespace definions at the SOAP envelope and 
> the Camel-CXF endpoint is configured in PAYLOAD mode the namespace definition 
> gets lost unless streaming is disabled.
> If the resulting CxfPayload is then converted e.g. to String that String will 
> contain invalid XML (because some namespace definition is missing).
> For non-streaming mode (system property 
> org.apache.camel.component.cxf.streaming is set to false) there are special 
> precautions met to set these envelope namespaces on the first DOM element of 
> the payload but this coding is missing for StAX.
> The messages in question look like that:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"; 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
> xmlns:xs="http://www.w3.org/2001/XMLSchema";>
>   <soap:Body>
>     <ns2:getTokenResponse xmlns:ns2="http://camel.apache.org/cxf/namespace";>
>       <return xsi:type="xs:string">Return Value</return>
>     </ns2:getTokenResponse>
>   </soap:Body>
> </soap:Envelope>
> If the CxfPayload is converted to String it will lack the definition for the 
> xsi namespace prefix (and further XML parsing will fail).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to