On Wednesday, June 08, 2011 6:09:45 AM Per Andersson wrote:
> Hi!
> This is kind of a strange question I guess, but anyway: Are there any
> possibilities to force cxf to "pretty print"/indent the request message it
> sends away?
There isn't anything "built in" but you could write an interceptor that does
it. The JAXB-impl jar we ship has an IndentingXMLStreamWriter that could
likely be uesed for this. (caveat, I haven't actually tried this) What you
would do is write a CXF interceptor that would live immediately after the
StaxoutIntereptor that would do something like:
XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
writer = new IndentingXMLStreamWriter(writer);
message.setContent(writer, XMLStreamWriter.class);
message.put(disable.outputstream.optimization", Boolean.TRUE);
That should do it, I think.
Dan
>
> Scenario: We have a server application that simply creates text files
> containing the requests it get's through a web service. When we send
> requests to this server using CXF on the client side (code example below)
> the creates text file has all content on one single line. If we use
> Soap-UI to send the same request, the created file contains line breaks
> and white spaces (which makes it "human readable"). We want the same
> behavior when we use CXF, is is possible?
>
> CXF code on the client:
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> Map<String, Object> properties = new HashMap<String, Object>();
> if (useMtom)
> {
> properties.put("mtom-enabled", Boolean.TRUE);
> }
> factory.setProperties(properties);
> factory.setServiceClass(MyCustomPortType.class);
> factory.setAddress(url);
> service = (MyCustomPortType) factory.create();
> service.sendMessage(myMessage);
>
>
> The resulting file when sending the request with soap-UI:
> <dummy>
> <dummy2>
> <dummy3>value</dummy3>
> </dummy2>
> </dummy>
>
> The resulting file when sending the same request with soup-UI:
> <dummy><dummy2><dummy3>value</dummy3></dummy2></dummy>
>
> //Per
--
Daniel Kulp
[email protected]
http://dankulp.com/blog
Talend - http://www.talend.com