Author: asankha
Date: Fri Apr 27 06:46:19 2007
New Revision: 533096

URL: http://svn.apache.org/viewvc?view=rev&rev=533096
Log:
fix mtom issue seen in windows and make the content type decision and message 
formatter selection clear and robust

Modified:
    
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/Axis2HttpRequest.java
    
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java

Modified: 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/Axis2HttpRequest.java
URL: 
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/Axis2HttpRequest.java?view=diff&rev=533096&r1=533095&r2=533096
==============================================================================
--- 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/Axis2HttpRequest.java
 (original)
+++ 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/Axis2HttpRequest.java
 Fri Apr 27 06:46:19 2007
@@ -68,6 +68,12 @@
         this.epr = epr;
         this.httpHost = httpHost;
         this.msgContext = msgContext;
+        this.format = Util.getOMOutputFormat(msgContext);
+        try {
+            messageFormatter = TransportUtils.getMessageFormatter(msgContext);
+        } catch (AxisFault axisFault) {
+            log.error("Cannot find a suitable MessageFormatter : " + 
axisFault.getMessage());
+        }
         try {
             this.pipe = new PipeImpl();
         } catch (IOException e) {
@@ -131,13 +137,7 @@
                 soapAction);
         }
 
-        format = Util.getOMOutputFormat(msgContext);
-        try {
-            messageFormatter = TransportUtils.getMessageFormatter(msgContext);
-        } catch (AxisFault axisFault) {
-            throw new IOException(
-                "Cannot find a suitable MessageFormatter : " + 
axisFault.getMessage());
-        }
+
         httpRequest.setHeader(
             HTTP.CONTENT_TYPE,
             messageFormatter.getContentType(msgContext, format, 
msgContext.getSoapAction()));
@@ -163,13 +163,6 @@
 
         log.debug("start streaming outgoing http request");
         OutputStream out = Channels.newOutputStream(pipe.sink());
-
-        if (format == null) {
-            format = Util.getOMOutputFormat(msgContext);
-        }
-        if (messageFormatter == null) {
-            messageFormatter = TransportUtils.getMessageFormatter(msgContext);
-        }
 
         messageFormatter.writeTo(msgContext, format, out, true);
             try {

Modified: 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java
URL: 
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java?view=diff&rev=533096&r1=533095&r2=533096
==============================================================================
--- 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java
 (original)
+++ 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java
 Fri Apr 27 06:46:19 2007
@@ -330,28 +330,26 @@
 
     private void sendUsingOutputStream(MessageContext msgContext) throws 
AxisFault {
         OMOutputFormat format = Util.getOMOutputFormat(msgContext);
-        OutputStream out =
-            (OutputStream) msgContext
-                .getProperty(MessageContext.TRANSPORT_OUT);
+        MessageFormatter messageFormatter = 
TransportUtils.getMessageFormatter(msgContext);
+        OutputStream out = (OutputStream) 
msgContext.getProperty(MessageContext.TRANSPORT_OUT);
 
         if (msgContext.isServerSide()) {
             OutTransportInfo transportInfo =
                 (OutTransportInfo) 
msgContext.getProperty(Constants.OUT_TRANSPORT_INFO);
 
             if (transportInfo != null) {
-                String encoding = Util.getContentType(msgContext) + "; 
charset=" + format.getCharSetEncoding();
-                transportInfo.setContentType(encoding);
+                transportInfo.setContentType(
+                messageFormatter.getContentType(msgContext, format, 
msgContext.getSoapAction()));
             } else {
                 throw new AxisFault(Constants.OUT_TRANSPORT_INFO + " has not 
been set");
             }
         }
 
         try {
-            (msgContext.isDoingREST() ?
-                msgContext.getEnvelope().getBody().getFirstElement() : 
msgContext.getEnvelope())
-                .serializeAndConsume(out, format);
-        } catch (XMLStreamException e) {
-            handleException("Error serializing response message", e);
+            messageFormatter.writeTo(msgContext, format, out, true);
+            out.close();
+        } catch (IOException e) {
+            handleException("IO Error sending response message", e);
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to