@@ -61,50 +61,9 @@ public byte[] getBytes(MessageContext
6161 public byte [] getBytes (MessageContext messageContext ,
6262 OMOutputFormat format ,
6363 boolean preserve ) throws AxisFault {
64-
65- if (log .isDebugEnabled ()) {
66- log .debug ("start getBytes()" );
67- log .debug (" fault flow=" +
68- (messageContext .getFLOW () == MessageContext .OUT_FAULT_FLOW ));
69- }
70- try {
71- OMElement omElement ;
72-
73- // Find the correct element to serialize. Normally it is the first element
74- // in the body. But if this is a fault, use the detail entry element or the
75- // fault reason.
76- if (messageContext .getFLOW () == MessageContext .OUT_FAULT_FLOW ) {
77- SOAPFault fault = messageContext .getEnvelope ().getBody ().getFault ();
78- SOAPFaultDetail soapFaultDetail = fault .getDetail ();
79- omElement = soapFaultDetail .getFirstElement ();
80-
81- if (omElement == null ) {
82- omElement = fault .getReason ();
83- }
84-
85- } else {
86- // Normal case: The xml payload is the first element in the body.
87- omElement = messageContext .getEnvelope ().getBody ().getFirstElement ();
88- }
89- ByteArrayOutputStream bytesOut = new ByteArrayOutputStream ();
90-
91- if (omElement != null ) {
92-
93- try {
94- omElement .serialize (bytesOut , format , preserve );
95- } catch (IOException e ) {
96- throw AxisFault .makeFault (e );
97- }
98-
99- return bytesOut .toByteArray ();
100- }
101-
102- return new byte [0 ];
103- } finally {
104- if (log .isDebugEnabled ()) {
105- log .debug ("end getBytes()" );
106- }
107- }
64+ ByteArrayOutputStream bytesOut = new ByteArrayOutputStream ();
65+ writeTo (messageContext , format , bytesOut , preserve );
66+ return bytesOut .toByteArray ();
10867 }
10968
11069 public void writeTo (MessageContext messageContext , OMOutputFormat format ,
0 commit comments