|
Hello! I am trying to modify the method which is requested by
SOAP message with XSLT to be redirected to another method in the service but my
changes to the soap envelope doesn’t seem to be reflected since I always get
the original method replay back. The SOAP envelope looks ok when serializing it
to a file. Anyone having any suggestions?? // Anders My code: public class HandlerXSLT extends BasicHandler { public void invoke(MessageContext msgContext) throws
AxisFault { SOAPPart rqPart = null; DOMSource src = ""> Message rqMsg = null; String tmp = null; Message rpMsg =null; try { rqMsg = msgContext.getRequestMessage(); rqPart = (SOAPPart) rqMsg.getSOAPPart(); src = "" rqPart.getContent(); tmp = rqPart.getAsString(); } catch(Exception e){ throw new AxisFault(); } try { TransformerFactory tFactory =
TransformerFactory.newInstance(); if(tFactory.getFeature(DOMSource.FEATURE) &&
tFactory.getFeature(DOMResult.FEATURE)) { DocumentBuilderFactory dFactory =
DocumentBuilderFactory.newInstance(); dFactory.setNamespaceAware(true); DocumentBuilder dBuilder =
dFactory.newDocumentBuilder(); Document xslDoc = dBuilder.parse("/tmp/uppg3.xsl"); DOMSource xslDomSource = new DOMSource(xslDoc); xslDomSource.setSystemId("uppg3.xsl"); Transformer transformer =
tFactory.newTransformer(xslDomSource); File file = new File("/tmp/SOAP.out"); Result domResult = new StreamResult(file); DOMResult res = new DOMResult(); transformer.transform(src, domResult); transformer.transform(src,res); rqPart.setContent(new DOMSource(res.getNode())); rqMsg.saveChanges(); msgContext.setRequestMessage(rqMsg); } else { throw new
org.xml.sax.SAXNotSupportedException("DOM node processing not
supported!"); } } catch (Exception e) { } try { File filep = new File("/tmp/SOAP-org.out"); FileWriter fw = new FileWriter(filep); fw.write("SOAP req msg:\n"+tmp); fw.flush(); } catch (IOException e) { } } } |
