WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSupport implements HandlerAdapter, InitializingBean { @Override public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (HttpTransportConstants.METHOD_GET.equals(request.getMethod())) { WsdlDefinition definition = (WsdlDefinition) handler; Transformer transformer = createTransformer(); Source definitionSource = definition.getSource(); if (transformLocations || transformSchemaLocations) { DOMResult domResult = new DOMResult(); transformer.transform(definitionSource, domResult); Document definitionDocument = (Document) domResult.getNode(); if (transformLocations) { transformLocations(definitionDocument, request); } if (transformSchemaLocations) { transformSchemaLocations(definitionDocument, request); } definitionSource = new DOMSource(definitionDocument); } response.setContentType(CONTENT_TYPE); StreamResult responseResult = new StreamResult(response.getOutputStream()); transformer.transform(definitionSource, responseResult); } else { response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } return null; }  void setLocationExpression(String locationExpression); void setSchemaLocationExpression(String schemaLocationExpression); void setTransformLocations(boolean transformLocations); void setTransformSchemaLocations(boolean transformSchemaLocations); @Override long getLastModified(HttpServletRequest request, Object handler); @Override ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler); @Override boolean supports(Object handler); @Override void afterPropertiesSet(); static final String DEFAULT_LOCATION_EXPRESSION; static final String DEFAULT_SCHEMA_LOCATION_EXPRESSION; }
@Test public void handleGet() throws Exception { request.setMethod(HttpTransportConstants.METHOD_GET); String definition = "<definition xmlns='http: expect(definitionMock.getSource()).andReturn(new StringSource(definition)); replay(definitionMock); adapter.handle(request, response, definitionMock); assertXMLEqual(definition, response.getContentAsString()); verify(definitionMock); }
@Test public void handleNonGet() throws Exception { request.setMethod(HttpTransportConstants.METHOD_POST); replay(definitionMock); adapter.handle(request, response, definitionMock); Assert.assertEquals("METHOD_NOT_ALLOWED expected", HttpServletResponse.SC_METHOD_NOT_ALLOWED, response.getStatus()); verify(definitionMock); }