follow-on question to where to put XSLT in client webapp question...
My web service contains this method
@WebMethod public String sayHello()
{
logger.debug("entering");
String result = null;
DateTime currTime = new DateTime(); // now
result = "greetings from the web service! time is " + DATE_PATTERN.print( currTime);
logger.debug("exiting ");
return result;
}
which when called by localhost:8080/myWebService/sayHello returns
<soap:Envelope>
<soap:Body>
<ns2:sayHelloResponse>
<return>greetings from the web service! time is 2015-09-10T22:25:05.281</return>
</ns2:sayHelloResponse>
</soap:Body>
</soap:Envelope>
I've crafted a companion spring/hibernate webapp (client) to exercise this web service using this as a pattern
my client webapp contains WEB-INF/xslt/XSLTview.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<div align="center">
<xsl:apply-templates />
</div>
</body>
</html>
</xsl:template>
<xsl:template match="/sayHello">
Welcome from the web service where the time is:
<xsl:value-of select="return" />
</xsl:template>
</xsl:stylesheet>
and a controller containing
@RequestMapping(value="viewXSLT")
public ModelAndView viewXSLT(HttpServletRequest request,
HttpServletResponse response)
throws IOException
{
String xmlSource = formsWebServicePortProxy.sayHello();
Source source = new StreamSource( xmlSource);
// adds the XML source file to the model so the XsltView can detect
ModelAndView model = new ModelAndView("XSLTView");
model.addObject("xmlSource", source);
return model;
}
and my servlet-context.xml contains
<bean id="xsltViewResolver" class="org.springframework.web.servlet.view.xslt.XsltViewResolver">
<property name="order" value="1"/>
<property name="sourceKey" value="xmlSource"/>
<property name="viewClass" value="org.springframework.web.servlet.view.xslt.XsltView"/>
<property name="prefix" value="/WEB-INF/xsl/" />
<property name="suffix" value=".xsl" />
</bean>
the results of all this is localhost:8080/myWebClient/viewXSLT returns
javax.xml.transform.TransformerException:
com.sun.org.apache.xml.internal.utils.WrappedRuntimeException:
no protocol:
greetings from the web service! time is 2015-09-10T22:49:24.500
so the method on the service is getting called but something's not right in my controller method. What should I be doing to get the xslt to format the xml coming from the service' method to produce a html page?
TIA,
Still-learning Steve