final ResourceConfig rc = new ResourceConfig(WidgetsResource.class, ExtraResource.class);
rc.property(ServerProperties.WADL_GENERATOR_CONFIG, MyWadlGeneratorConfig.class.getName());
final ApplicationHandler applicationHandler = new ApplicationHandler(rc);
final ContainerResponse containerResponse = applicationHandler.apply(new ContainerRequest(
URI.create("/"), URI.create("/application.wadl"),
"GET", null, new MapPropertiesDelegate())).get();
final DocumentBuilderFactory bf = DocumentBuilderFactory.newInstance();
bf.setNamespaceAware(true);
bf.setValidating(false);
if (!SaxHelper.isXdkDocumentBuilderFactory(bf)) {
bf.setXIncludeAware(false);
}
final DocumentBuilder b = bf.newDocumentBuilder();
((ByteArrayInputStream) containerResponse.getEntity()).reset();
final Document d = b.parse((InputStream) containerResponse.getEntity());
printSource(new DOMSource(d));
final XPath xp = XPathFactory.newInstance().newXPath();
xp.setNamespaceContext(new SimpleNamespaceResolver("wadl", "http://wadl.dev.java.net/2009/02"));
// check base URI
final String val = (String) xp.evaluate("/wadl:application/wadl:resources/@base", d, XPathConstants.STRING);