public class XMLResult implements Result {
private String doc = null;
private Logger logger = Logger.getLogger(getClass().getName());
public void execute(ActionInvocation invocation) throws Exception {
ServletActionContext.getResponse().setContentType("text/plain");
PrintWriter out = ServletActionContext.getResponse().getWriter();
ValueStack valueStack = invocation.getStack();
Document docOut = (Document) valueStack.findValue(doc);
TransformerFactory transfac = TransformerFactory.newInstance();
Transformer trans = transfac.newTransformer();
trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
trans.setOutputProperty(OutputKeys.INDENT, "yes");
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(docOut);
trans.transform(source, result);
String xmlString = sw.toString();
out.write(xmlString);
out.close();
}
public void setDoc(String doc) {
this.doc = doc;
}
public String getDoc() {
return doc;
}
}
...
resultDoc
Reference: struts to ws
SOAP web service
http://www.mkyong.com/webservices/jax-ws/jax-ws-hello-world-example-document-style/
http://www.mkyong.com/webservices/jax-ws/jax-ws-spring-integration-example/
SOAP or REST
http://searchsoa.techtarget.com/tip/REST-vs-SOAP-How-to-choose-the-best-Web-service
JAX-RPC versus JAX-WS
http://www.ibm.com/developerworks/library/ws-tip-jaxwsrpc/
http://tutorials.jenkov.com/java-collections/sorting.html
http://javarevisited.blogspot.com/2011/11/collection-interview-questions-answers.html
http://www.developersbook.com/corejava/interview-questions/corejava-interview-questions-faqs-2.php