Thanks Daniel. I worked that out about an hour ago and am implementing it now!
Thanks for the quick reply though. It's a shame there's not an out of the box interceptor for this as it's probably a pretty common use case. Regards Mike On 18/03/2014 9:06 AM, "Daniel Kulp" <dk...@apache.org> wrote: > > Using a transform for this won't work as the XML parser (woodstox in our > case) would still not be able to parse the XML. > > The only way to handle this would be to write an interceptor that would > run prior to the StaxInInterceptor that would take the InputSteam and > wrapper it with a new InputStream that would convert the bytes to valid > values during the read(..) methods. Basically, fix it at the stream level. > > Dan > > > On Mar 17, 2014, at 4:39 AM, Mike Watson <michael.f.wat...@gmail.com> > wrote: > > > Hi, > > > > I'm using CXF in a client that is consuming the MS Exchange Web Service > > (EWS). > > > > I'm finding that one of the elements returned by this service > (UniqueHash) > > contains characters that are invalid in XML v1.0. As I have no control > over > > this I'm trying to use an inbound interceptor to drop the UniqueHash > > elements (I don't need them) like this: > > > > Map<String, String> inTransformMap = Collections.singletonMap( > > "{http://schemas.microsoft.com/exchange/services/2006/types}UniqueHash", > > ""); > > TransformInInterceptor transformInInterceptor = new > > TransformInInterceptor(); > > transformInInterceptor.setInTransformElements(inTransformMap); > > client.getInInterceptors().add(transformInInterceptor); > > > > > > I can see that the transform is running nice and early (post-stream): > > > > FINE: Chain org.apache.cxf.phase.PhaseInterceptorChain@be78549 was > created. > > Current flow: > > receive [PolicyInInterceptor, LoggingInInterceptor, > > AttachmentInInterceptor] > > post-stream [TransformInInterceptor, StaxInInterceptor] > > read [WSDLGetInterceptor, ReadHeadersInterceptor, > > SoapActionInInterceptor, StartBodyInterceptor] > > pre-protocol [MustUnderstandInterceptor] > > post-protocol [CheckFaultInterceptor, > JAXBAttachmentSchemaValidationHack] > > unmarshal [DocLiteralInInterceptor, SoapHeaderInterceptor] > > post-logical [WrapperClassInInterceptor] > > pre-invoke [SwAInInterceptor, HolderInInterceptor] > > > > > > But even though it *appears* to be working as intended stepping through > the > > code, when DocLiteralInInterceptor fires later on it throws this > > unmarshalling error (0x5 in this case is within the UniqueHash element I > > thought I'd dropped): > > > > org.apache.cxf.interceptor.Fault: Unmarshalling Error: Illegal character > > entity: expansion character (code 0x5 > > at [row,col {unknown-source}]: [1,2574] > > at > > > org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:881) > > at > > > org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:702) > > at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:160) > > at > > > org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:192) > > > > Does anyone know what I'm doing wrong here? Any pointers on how I get rid > > of this element and it's troublesome content? > > > > BTW I'm using CXF v2.7.10 with Java 7. > > > > Kind regards, > > Mike > > -- > Daniel Kulp > dk...@apache.org - http://dankulp.com/blog > Talend Community Coder - http://coders.talend.com > >