M
moralbarometer
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
aram 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
therwise>
</xsl
therwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
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
<xsl:template match="/">
<xsl:choose>
<xsl:when test="$action='serializeAxisFaultFromSOAPEnvelope'">
<xsl:copy-of select="soap:Envelope/soap:Body/soap:fault"/>
</xsl:when>
<xsl
</xsl
</xsl:choose>
</xsl:template>
</xsl:stylesheet>