You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2018/12/22 11:09:32 UTC
svn commit: r1849539 -
/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java
Author: veithen
Date: Sat Dec 22 11:09:31 2018
New Revision: 1849539
URL: http://svn.apache.org/viewvc?rev=1849539&view=rev
Log:
Reduce code duplication in ApplicationXMLFormatter.
Modified:
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java?rev=1849539&r1=1849538&r2=1849539&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/http/ApplicationXMLFormatter.java Sat Dec 22 11:09:31 2018
@@ -61,50 +61,9 @@ public class ApplicationXMLFormatter imp
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));
- }
- 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();
- omElement = soapFaultDetail.getFirstElement();
-
- if (omElement == null) {
- omElement = fault.getReason();
- }
-
- } else {
- // Normal case: The xml payload is the first element in the body.
- omElement = messageContext.getEnvelope().getBody().getFirstElement();
- }
- ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
-
- if (omElement != null) {
-
- try {
- omElement.serialize(bytesOut, format, preserve);
- } catch (IOException e) {
- throw AxisFault.makeFault(e);
- }
-
- return bytesOut.toByteArray();
- }
-
- return new byte[0];
- } finally {
- if (log.isDebugEnabled()) {
- log.debug("end getBytes()");
- }
- }
+ ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
+ writeTo(messageContext, format, bytesOut, preserve);
+ return bytesOut.toByteArray();
}
public void writeTo(MessageContext messageContext, OMOutputFormat format,