axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sami...@apache.org
Subject svn commit: r396107 - in /webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer: client/MTOMClientModel.java service/MTOMService.java
Date Sat, 22 Apr 2006 10:35:05 GMT
Author: saminda
Date: Sat Apr 22 03:35:01 2006
New Revision: 396107

URL: http://svn.apache.org/viewcvs?rev=396107&view=rev
Log:
Fixed mtom Sample. 

Modified:
    webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClientModel.java
    webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/MTOMService.java

Modified: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClientModel.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClientModel.java?rev=396107&r1=396106&r2=396107&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClientModel.java
(original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClientModel.java
Sat Apr 22 03:35:01 2006
@@ -71,8 +71,9 @@
             imageName.setText(fileName);
         }
         //OMElement wrap = fac.createOMElement("wrap",omNs);
-        data.addChild(image);
+//        data.addChild(image);
         data.addChild(imageName);
+        data.addChild(image);
         //data.addChild(wrap);
         return data;
 

Modified: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/MTOMService.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/MTOMService.java?rev=396107&r1=396106&r2=396107&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/MTOMService.java
(original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/MTOMService.java
Sat Apr 22 03:35:01 2006
@@ -22,22 +22,42 @@
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMText;
+import org.apache.axis2.AxisFault;
 
 import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
 import java.awt.*;
 import java.io.FileOutputStream;
+import java.util.Iterator;
 
 public class MTOMService {
-    
+
     public OMElement mtomSample(OMElement element) throws Exception {
-    	
-        OMElement imageEle = element.getFirstElement();
-        OMElement imageName = (OMElement) imageEle.getNextOMSibling();
-        OMText binaryNode = (OMText) imageEle.getFirstOMChild();
-        String fileName = imageName.getText();
+
+        OMElement _fileNameEle = null;
+        OMElement _imageElement = null;
+
+        for (Iterator _iterator = element.getChildElements(); _iterator.hasNext();) {
+             OMElement _ele = (OMElement) _iterator.next();
+            if (_ele.getLocalName().equalsIgnoreCase("fileName")) {
+                  _fileNameEle = _ele;
+            }
+            if (_ele.getLocalName().equalsIgnoreCase("image")) {
+                  _imageElement = _ele;
+            }
+        }
+
+        if (_fileNameEle == null || _imageElement == null ) {
+            throw new AxisFault("Either Image or FileName is null");
+        }
+
+        OMText binaryNode = (OMText) _imageElement.getFirstOMChild();
+
+        String fileName = _fileNameEle.getText();
+
         //Extracting the data and saving
         DataHandler actualDH;
-        actualDH = (DataHandler)binaryNode.getDataHandler();
+        actualDH = (DataHandler) binaryNode.getDataHandler();
         Image actualObject = new ImageIO().loadImage(actualDH.getDataSource()
                 .getInputStream());
         FileOutputStream imageOutStream = new FileOutputStream(fileName);



Mime
View raw message