You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2007/08/18 15:25:25 UTC
svn commit: r567267 -
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java
Author: scheu
Date: Sat Aug 18 06:25:18 2007
New Revision: 567267
URL: http://svn.apache.org/viewvc?view=rev&rev=567267
Log:
ApplicationXMLFormatter.writeTo(..) is not respecting the "preserve" parameter.
Changed the code to not consume the OM when preserve is true.
Contributor:Rich Scheuerle
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java?view=diff&rev=567267&r1=567266&r2=567267
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java Sat Aug 18 06:25:18 2007
@@ -45,15 +45,35 @@
public class ApplicationXMLFormatter implements MessageFormatter {
private static final Log log = LogFactory.getLog(ApplicationXMLFormatter.class);
- public byte[] getBytes(MessageContext messageContext, OMOutputFormat format) throws AxisFault {
+ public byte[] getBytes(MessageContext
+ messageContext,
+ OMOutputFormat format) throws AxisFault {
+ return getBytes(messageContext, format, false);
+ }
+
+ /**
+ * Get the bytes for this message
+ * @param messageContext
+ * @param format
+ * @param preserve (indicates if the OM should be preserved or consumed)
+ * @return
+ * @throws AxisFault
+ */
+ public byte[] getBytes(MessageContext messageContext,
+ OMOutputFormat format,
+ boolean preserve) throws AxisFault {
if (log.isDebugEnabled()) {
log.debug("start getBytes()");
- log.debug(" fault flow=" + (messageContext.getFLOW() == MessageContext.OUT_FAULT_FLOW));
+ log.debug(" fault flow=" +
+ (messageContext.getFLOW() == MessageContext.OUT_FAULT_FLOW));
}
try {
OMElement omElement;
+ // Find the correct element to serialize. Normally it is the first element
+ // in the body. But if this is a fault, use the detail entry element or the
+ // fault reason.
if (messageContext.getFLOW() == MessageContext.OUT_FAULT_FLOW) {
SOAPFault fault = messageContext.getEnvelope().getBody().getFault();
SOAPFaultDetail soapFaultDetail = fault.getDetail();
@@ -64,6 +84,7 @@
}
} else {
+ // Normal case: The xml payload is the first element in the body.
omElement = messageContext.getEnvelope().getBody().getFirstElement();
}
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
@@ -71,7 +92,11 @@
if (omElement != null) {
try {
- omElement.serializeAndConsume(bytesOut, format);
+ if (preserve) {
+ omElement.serialize(bytesOut, format);
+ } else {
+ omElement.serializeAndConsume(bytesOut, format);
+ }
} catch (XMLStreamException e) {
throw AxisFault.makeFault(e);
}
@@ -111,7 +136,11 @@
}
if (omElement != null) {
try {
- omElement.serializeAndConsume(outputStream, format);
+ if (preserve) {
+ omElement.serialize(outputStream, format);
+ } else {
+ omElement.serializeAndConsume(outputStream, format);
+ }
} catch (XMLStreamException e) {
throw AxisFault.makeFault(e);
}
@@ -166,7 +195,9 @@
return contentType;
}
- public URL getTargetAddress(MessageContext messageContext, OMOutputFormat format, URL targetURL)
+ public URL getTargetAddress(MessageContext messageContext,
+ OMOutputFormat format,
+ URL targetURL)
throws AxisFault {
// Check whether there is a template in the URL, if so we have to replace then with data
@@ -186,7 +217,8 @@
return true;
}
// search for "type=text/xml"
- else if (JavaUtils.indexOfIgnoreCase(contentType, SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
+ else if (JavaUtils.indexOfIgnoreCase(contentType,
+ SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
return true;
}
return false;
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org