@Bean(name = "helloEndpoint") public CxfEndpoint userServiceEndpoint() { CxfEndpoint cxfEndpoint = new CxfEndpoint(); cxfEndpoint.setAddress("http://localhost:8888/services/hello"); cxfEndpoint.setServiceClass(HelloWorld.class); LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor(); loggingInInterceptor.setPrettyLogging(true); LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor(); loggingOutInterceptor.setPrettyLogging(true); cxfEndpoint.getOutInterceptors().add(loggingOutInterceptor); cxfEndpoint.getInInterceptors().add(loggingInInterceptor); cxfEndpoint.setDataFormat(DataFormat.POJO); final Map<String, Object> properties = new HashMap<>(); properties.put("schema-validation-enabled", "true"); properties.put("bus.jmx.enabled", "true"); //properties.setProperty("faultStackTraceEnabled", "true"); //properties.setProperty("exceptionMessageCauseEnabled", "true"); //properties.setProperty("schema-validation-enabled", "false"); //properties.put("allowStreaming", true); cxfEndpoint.configureProperties(properties); return cxfEndpoint; }
@Override public void overrideEndpoint(Endpoint endpoint) { if (endpoint instanceof CxfEndpoint) { ((CxfEndpoint) endpoint).setDataFormat(DataFormat.PAYLOAD); //Works around issue: https://issues.apache.org/jira/browse/CXF-2775 System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", "true"); } }
@Converter public static DataFormat toDataFormat(final String name) { return DataFormat.valueOf(name.toUpperCase()); }
@SuppressWarnings("deprecation") @Test public void testGetDataFormatMessage() throws Exception { CxfEndpoint endpoint = createEndpoint(getEndpointURI() + sepChar() + "dataFormat=MESSAGE"); assertEquals("We should get the Message DataFormat", DataFormat.MESSAGE, endpoint.getDataFormat()); }
@Test public void testGetDataFormatCXF() throws Exception { CxfEndpoint endpoint = createEndpoint(getEndpointURI() + sepChar() + "dataFormat=CXF_MESSAGE"); assertEquals("We should get the Message DataFormat", DataFormat.CXF_MESSAGE, endpoint.getDataFormat()); }
@Test public void testGetDataFormatRAW() throws Exception { CxfEndpoint endpoint = createEndpoint(getEndpointURI() + sepChar() + "dataFormat=RAW"); assertEquals("We should get the Message DataFormat", DataFormat.RAW, endpoint.getDataFormat()); }
@Test public void testGetDataFormatFromCxfEndpontProperties() throws Exception { CxfEndpoint endpoint = createEndpoint(getEndpointURI() + "?dataFormat=PAYLOAD"); assertEquals("We should get the PAYLOAD DataFormat", DataFormat.PAYLOAD, endpoint.getDataFormat()); }