![]() |
Does it mean source and result should both be either DOM or Stream or SAX and not mixed?
Hi all,
I intend to retrieve the fault node as a a string from the soap message. When i used transform(DOMSource,StreamResult) i get just the <?xml version="1.0" encoding="UTF-8"?> as string. but when i use transform(StreamSource,StreamResult) i get the expected String of fault Node. where am i wrong?. transform(DOMSource,StreamResult) and transform(StreamSource,StreamResult) are they different . Does it mean source and result should both be either DOM or Stream or SAX and not mixed? See information below public String doSerialization(Message soapMsg) { StreamSource sourceXSL=new StreamSource(Thread.currentThread().getClass() .getClassLoader().getResourceAsStream("de/ AxisFaultProcessor.xsl")); DOMSource domSource=new DOMSource(soapMsg.getSOAPEnvelope().getAsDocument( )); ByteArrayOutputStream out=new ByteArrayOutputStream(); StreamResult streamResult=new StreamResult(out); TransformerFactory transformerFactory =TransformerFactory.newInstance(); Transformer transformer =transformerFactory.newTransformer(sourceXSL); transformer.setParameter("action", "serializeAxisFaultFromSOAPEnvelope"); transformer.setOutputProperty("method", "xml"); transformer.transform(domSource, streamResult); return out.toString(); } /// XSL below <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" > <xsl:param name="action" /> <xsl:template match="/"> <xsl:choose> <xsl:when test="$action='serializeAxisFaultFromSOAPEnvelope' "> <xsl:copy-of select="soap:Envelope/soap:Body/soap:fault"/> </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> |
Re: Does it mean source and result should both be either DOM or Streamor SAX and not mixed?
moralbarometer wrote:
> When i used transform(DOMSource,StreamResult) Mixing these should be no problem, so I'm presuming the error is something else, such as a DOM that isn't providing information this XSLT processor needs. Are you absolutely sure soapMsg is a namespace-aware DOM Level 2 DOM instance? (That is, do the elements have namespaces and localnames, or only node names?) -- () ASCII Ribbon Campaign | Joe Kesselman /\ Stamp out HTML e-mail! | System architexture and kinetic poetry |
Re: Does it mean source and result should both be either DOM or Stream or SAX and not mixed?
Hi Joe,
thx for the prompt reply. see below the i have used for testing the xml below: <?xml version='1.0' ?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <soap:fault> <soap:code> <soap:value>X90</soap:value> <soap:subcode> <soap:value>Y90</soap:value> </soap:subcode> </soap:code> <soap:reason> <soap:text>remote exception occurred during this period</soap:text> <soap:text>This reason has been logged in our system for further references please consult with the number ID</soap:text> </soap:reason> <soap:detail> <message>3-Piece luggage set. Black Polyester</message> <id>100</id> </soap:detail> </soap:fault> </soap:Body> </soap:Envelope> |
Re: Does it mean source and result should both be either DOM or Streamor SAX and not mixed?
That isn't what I asked. Yes, your input document uses namespaces. Does
the DOM display them correctly? If not, whatever's building the DOM has to be fixed. |
Re: Does it mean source and result should both be either DOM or Stream or SAX and not mixed?
the code below shows how i created the DOMSource
Is there any error in it? thx InuputStream confiXML=StreamSource(Thread.currentThread().getCl ass() .getClassLoader().getResourceAsStream("de/ SOAP.xml")); DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newI nstance(); DocumentBuilder documentBuilder=documentBuilderFactory.newDocument Builder(); Document document=documentBuilder.parse(confiXML); DOMSource domSource=new DOMSource(document); |
Re: Does it mean source and result should both be either DOM or Streamor SAX and not mixed?
moralbarometer wrote:
> the code below shows how i created the DOMSource > Is there any error in it? > thx > > InuputStream confiXML=StreamSource(Thread.currentThread().getCl ass() > .getClassLoader().getResourceAsStream("de/ > SOAP.xml")); > > DocumentBuilderFactory > documentBuilderFactory=DocumentBuilderFactory.newI nstance(); // Add this line. (Arguably should be the default these days, but // generally isn't for historical reasons of compatability with // ancient code.) documentBuilderFatory.setNamespaceAware(true); > DocumentBuilder > documentBuilder=documentBuilderFactory.newDocument Builder(); > Document document=documentBuilder.parse(confiXML); > DOMSource domSource=new DOMSource(document); -- Joe Kesselman / Beware the fury of a patient man. -- John Dryden |
Re: Does it mean source and result should both be either DOM or Streamor SAX and not mixed?
Joseph Kesselman wrote:
> documentBuilderFatory.setNamespaceAware(true); Should of course have been ...Factory.set... (Sorry. Free, typo-free, useful; pick any two.) -- Joe Kesselman / Beware the fury of a patient man. -- John Dryden |
Re: Does it mean source and result should both be either DOM or Stream or SAX and not mixed?
Hallo Joe,
Thanks alot. it works well. have a nice weekend |
Re: Does it mean source and result should both be either DOM or Stream or SAX and not mixed?
Hi all,
is namespace enabled when retreiving document from SOAPMessage. AXIS is used in this case. As shown below DOMSource domSource=new DOMSource(soapMsg.getSOAPEnvelope().getAsDocument( )); thanks |
| All times are GMT. The time now is 03:45 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.