This is only possible if the remote server supports pure XML responses. Most of the servers which do support both Fastinfoset and pure XML are looking into Accept
header from the request to decide in which format to return the response.
So you can try to force the XML response by sending the Accept: application/xml
header with each of your requests.
For that you will need to create a CXF out interceptor and register it with your application.
Following Interceptor will always set Accept: application/xml
public class HttpHeaderInterceptor extends AbstractPhaseInterceptor<Message>{
public XmlOnlyInterceptor() {
super(Phase.POST_PROTOCOL);
}
@Override
public void handleMessage(Message message) throws Fault {
Map<String, List> headers = (Map<String, List>)message.get(Message.PROTOCOL_HEADERS);
headers.put("Accept", Collections.singletonList("application/xml"));
}
}
To register it use follwoing configuration
<jaxws:client id="clientBean" serviceClass="org.example.service.ServicePortType"
address="example.org/src/service/ServicePort">
<jaxws:outInterceptors>
<bean class="org.example.interceptor.HttpHeaderInterceptor"/>
</jaxws:outInterceptors>
</jaxws:client>