Author: thilina
Date: Tue Jul 26 05:42:45 2005
New Revision: 225292

URL: http://svn.apache.org/viewcvs?rev=225292&view=rev
Log:
Commiting the interop service and some other changes due to addition of utils 
package to o.a.a2.attachements

Added:
    webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/
    webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/
    
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClient.java
   (with props)
    
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClientModel.java
   (with props)
    
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/UserInterface.java
   (with props)
    webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/service/
    
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/service/META-INF/
    
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/service/META-INF/service.xml
   (with props)
    
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/service/interopService.java
Modified:
    
webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
    
webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java
    
webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMTest.java
    
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMTextImpl.java
    
webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/attachments/ImageSampleTest.java

Modified: 
webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?rev=225292&r1=225291&r2=225292&view=diff
==============================================================================
--- 
webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
 (original)
+++ 
webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
 Tue Jul 26 05:42:45 2005
@@ -227,7 +227,7 @@
         /*

          * put a reference to Attachments in to the message context

          */

-        msgContext.setProperty("Attachments", mimeHelper);

+        msgContext.setProperty(MIMEHelper.ATTACHMENTS, mimeHelper);

         if (mimeHelper.getAttachmentSpecType().equals(MIMEHelper.MTOM_TYPE)) {

             /*

              * Creates the MTOM specific MTOMStAXSOAPModelBuilder


Added: 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClient.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClient.java?rev=225292&view=auto
==============================================================================
--- 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClient.java
 (added)
+++ 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClient.java
 Tue Jul 26 05:42:45 2005
@@ -0,0 +1,39 @@
+ /*

+ * Copyright 2004,2005 The Apache Software Foundation.

+ * 

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not

+ * use this file except in compliance with the License. You may obtain a copy 
of

+ * the License at

+ * 

+ * http://www.apache.org/licenses/LICENSE-2.0

+ * 

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT

+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the

+ * License for the specific language governing permissions and limitations 
under

+ * the License.

+ */

+package sample.mtom.interop.client;

+

+import javax.swing.*;

+import java.awt.*;

+

+public class InteropClient extends JFrame {

+

+    public InteropClient(String title) throws HeadlessException {

+        super(title);

+

+        this.getContentPane().add(new UserInterface(this));

+        this.show();

+    }

+

+    public static void main(String[] args) {

+        InteropClient form = new InteropClient("Interop Client");

+        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

+        form.setLocation(screenSize.width / 4 - 20,

+                screenSize.height / 4);

+        form.setSize(screenSize.width / 2 - 80, screenSize.height / 2);

+        form.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

+        form.show();

+    }

+}


Propchange: 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClient.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClientModel.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClientModel.java?rev=225292&view=auto
==============================================================================
--- 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClientModel.java
 (added)
+++ 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClientModel.java
 Tue Jul 26 05:42:45 2005
@@ -0,0 +1,83 @@
+/*

+ * Copyright 2004,2005 The Apache Software Foundation.

+ * 

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not

+ * use this file except in compliance with the License. You may obtain a copy 
of

+ * the License at

+ * 

+ * http://www.apache.org/licenses/LICENSE-2.0

+ * 

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT

+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the

+ * License for the specific language governing permissions and limitations 
under

+ * the License.

+ */

+package sample.mtom.interop.client;

+

+import java.io.File;

+

+import javax.activation.DataHandler;

+import javax.activation.FileDataSource;

+import javax.xml.namespace.QName;

+

+import org.apache.axis2.Constants;

+import org.apache.axis2.addressing.AddressingConstants;

+import org.apache.axis2.addressing.EndpointReference;

+import org.apache.axis2.clientapi.Call;

+import org.apache.axis2.om.OMAbstractFactory;

+import org.apache.axis2.om.OMElement;

+import org.apache.axis2.om.OMFactory;

+import org.apache.axis2.om.OMNamespace;

+import org.apache.axis2.om.OMText;

+

+

+public class InteropClientModel {

+    private File inputFile = null;

+

+    private EndpointReference targetEPR = new EndpointReference(

+            AddressingConstants.WSA_TO,

+            "http://127.0.0.1:8080/axis2/services/interopService";);

+

+    private QName operationName = new QName("mtomSample");

+

+

+    public InteropClientModel() {

+

+    }

+

+    private OMElement createEnvelope(String fileName) throws Exception {

+

+        DataHandler expectedDH;

+        OMFactory fac = OMAbstractFactory.getOMFactory();

+        OMNamespace omNs = 
fac.createOMNamespace("http://example.org/mtom/data";, "x");

+        OMElement data = fac.createOMElement("Data", omNs);

+        

+        File dataFile = new File(fileName);

+        FileDataSource dataSource = new FileDataSource(dataFile);

+        expectedDH = new DataHandler(dataSource);

+        OMText textData = fac.createText(expectedDH, true);

+        data.addChild(textData);

+        return data;

+    }

+

+    public OMElement testEchoXMLSync(String fileName) throws Exception {

+

+        OMElement payload = createEnvelope(fileName);

+        Call call = new Call();

+        call.setTo(targetEPR);

+        // enabling MTOM in the client side

+        call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);

+        call.setTransportInfo(Constants.TRANSPORT_COMMONS_HTTP,

+                Constants.TRANSPORT_HTTP, false);

+        OMElement result = (OMElement) call.invokeBlocking(operationName

+                .getLocalPart(),

+                payload);

+        return result;

+    }

+

+    public void setTargetEPR(String targetEPR) {

+        this.targetEPR = new EndpointReference(AddressingConstants.WSA_TO,

+                targetEPR);

+    }

+}


Propchange: 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClientModel.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/UserInterface.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/UserInterface.java?rev=225292&view=auto
==============================================================================
--- 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/UserInterface.java
 (added)
+++ 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/UserInterface.java
 Tue Jul 26 05:42:45 2005
@@ -0,0 +1,160 @@
+/*

+ * Copyright 2004,2005 The Apache Software Foundation.

+ * 

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not

+ * use this file except in compliance with the License. You may obtain a copy 
of

+ * the License at

+ * 

+ * http://www.apache.org/licenses/LICENSE-2.0

+ * 

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT

+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the

+ * License for the specific language governing permissions and limitations 
under

+ * the License.

+ */

+package sample.mtom.interop.client;

+

+import java.awt.Container;

+import java.awt.Dimension;

+import java.awt.event.ActionEvent;

+import java.awt.event.ActionListener;

+import java.io.File;

+

+import javax.swing.JButton;

+import javax.swing.JFileChooser;

+import javax.swing.JLabel;

+import javax.swing.JOptionPane;

+import javax.swing.JPanel;

+import javax.swing.JTextArea;

+import javax.swing.JTextField;

+

+import org.apache.axis2.om.OMElement;

+

+public class UserInterface extends JPanel implements ActionListener {

+

+    JButton browse;

+

+    JButton send;

+

+    JTextArea jTextArea;

+

+    JFileChooser jFileChooser;

+

+    File file = null;

+

+    JTextField EPR;

+

+    JTextField fileName;

+

+    JTextField fileFeild;

+

+    JLabel label;

+

+    JLabel savefile;

+

+    private String desiredFileName = null;

+

+    private String EPRName = null;

+

+    private InteropClient parent;

+

+    public UserInterface(InteropClient parent) {

+        this.parent = parent;

+        EPR = new JTextField();

+        fileFeild = new JTextField();

+        fileName = new JTextField();

+        label = new JLabel("END Point:");

+        savefile = new JLabel("Desired File Name:");

+        jTextArea = new JTextArea(5, 5);

+        jTextArea.setPreferredSize(new Dimension(200, 100));

+

+        jFileChooser = new JFileChooser();

+        jFileChooser.setName("File Chooser");

+        this.browse = new JButton("Browse");

+        this.send = new JButton("Send The File");

+        fileFeild.setBounds(20, 20, 270, 20);

+        browse.setBounds(300, 20, 120, 20);

+        savefile.setBounds(20, 60, 200, 20);

+        fileName.setBounds(150, 60, 270, 20);

+

+        label.setBounds(20, 90, 200, 20);

+        EPR.setBounds(150, 90, 270, 20);

+

+        EPR.setText("http://127.0.0.1:8080/axis2/services/interopService";);

+

+        send.setBounds(140, 120, 150, 20);

+

+        jTextArea.setBounds(20, 150, 400, 180);

+

+        browse.addActionListener(this);

+        send.addActionListener(this);

+

+        Container pane = parent.getContentPane();

+        this.setLayout(null);

+

+        pane.add(browse);

+

+        pane.add(send);

+        pane.add(jTextArea);

+        pane.add(EPR);

+        pane.add(fileFeild);

+        pane.add(label);

+        pane.add(savefile);

+        pane.add(fileName);

+

+    }

+

+    public void actionPerformed(ActionEvent e) {

+

+        if (e.getSource() == browse) {

+

+            int returnVal = jFileChooser.showDialog(this,

+                    "Choose the File to Send");

+

+            if (returnVal == JFileChooser.APPROVE_OPTION) {

+                file = jFileChooser.getSelectedFile();

+                if (file.getAbsolutePath() != null) {

+                    fileFeild.setText(file.getAbsolutePath());

+                }

+            } 

+            jFileChooser.setSelectedFile(null);

+        }

+        if (e.getSource() == send) {

+            if (fileName.getText() != null) {

+                desiredFileName = fileName.getText();

+            }

+            if (file == null) {

+                JOptionPane.showMessageDialog(parent,

+                        "Attachments should not be null.", " error",

+                        JOptionPane.ERROR_MESSAGE);

+

+            } else if (("").equals(EPR.getText())) {

+                JOptionPane.showMessageDialog(parent, "END Point null",

+                        " error", JOptionPane.ERROR_MESSAGE);

+

+            } else {

+                EPRName = EPR.getText();

+                this.send(desiredFileName);

+            }

+

+        }

+    }

+

+    public void send(String fileName) {

+

+        InteropClientModel mtomTest = new InteropClientModel();

+

+        try {

+            mtomTest.setTargetEPR(EPRName);

+            OMElement result = (OMElement) mtomTest.testEchoXMLSync(fileName);

+//            jTextArea.setText(result.toString());

+//            jTextArea.append("\n"+result.getText());

+//            JOptionPane.showMessageDialog(parent, "Sent & saved Image 
Succesfully",

+//                    " Success", JOptionPane.PLAIN_MESSAGE);

+        } catch (Exception e) {

+            e.printStackTrace(); 

+        }

+

+    }

+}
\ No newline at end of file

Propchange: 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/client/UserInterface.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/service/META-INF/service.xml
URL: 
http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/service/META-INF/service.xml?rev=225292&view=auto
==============================================================================
--- 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/service/META-INF/service.xml
 (added)
+++ 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/service/META-INF/service.xml
 Tue Jul 26 05:42:45 2005
@@ -0,0 +1,9 @@
+<service name="MTOMService">

+    <description>

+        This is a sample Web Service with two operations,echo and ping.

+    </description>

+    <parameter name="ServiceClass" 
locked="xsd:false">sample.mtom.interop.service.interopService</parameter>

+    <operation name="interopService">

+        <messageReceiver 
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>

+    </operation>

+</service>
\ No newline at end of file

Propchange: 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/service/META-INF/service.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/service/interopService.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/service/interopService.java?rev=225292&view=auto
==============================================================================
--- 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/service/interopService.java
 (added)
+++ 
webservices/axis/trunk/java/modules/samples/src/sample/mtom/interop/service/interopService.java
 Tue Jul 26 05:42:45 2005
@@ -0,0 +1,45 @@
+/*
+ * Copyright  2004 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package sample.mtom.interop.service;
+
+import java.util.Iterator;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMText;
+
+/**
+ * @author <a href="mailto:[EMAIL PROTECTED]"> Thilina Gunarathne </a>
+ */
+public class interopService {
+    public OMElement mtomSample(OMElement element) throws Exception {
+        if (element.getLocalName().equalsIgnoreCase("Data")
+                && element.getNamespace().getName().equalsIgnoreCase(
+                        "http://example.org/mtom/data";)) {
+                OMText binaryNode = (OMText)element.getFirstChild();
+                binaryNode.setOptimize(!binaryNode.isOptimized());
+            }
+         else if (element.getLocalName().equalsIgnoreCase("EchoTest") && 
element.getNamespace().getName().equalsIgnoreCase("http://example.org/mtom/data";))
 {
+            Iterator childrenIterator = element.getChildren();
+            while (childrenIterator.hasNext()) {
+                OMElement dataElement = (OMElement) childrenIterator.next();
+                OMText binaryNode = (OMText)dataElement.getFirstChild();
+                binaryNode.setOptimize(!binaryNode.isOptimized());
+            }
+        }
+        return element;
+    }
+}
\ No newline at end of file

Modified: 
webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java?rev=225292&r1=225291&r2=225292&view=diff
==============================================================================
--- 
webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java
 (original)
+++ 
webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java
 Tue Jul 26 05:42:45 2005
@@ -30,8 +30,8 @@
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.attachments.ImageDataSource;
-import org.apache.axis2.attachments.JDK13IO;
+import org.apache.axis2.attachments.utils.ImageDataSource;
+import org.apache.axis2.attachments.utils.JDK13IO;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.description.ServiceDescription;

Modified: 
webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMTest.java?rev=225292&r1=225291&r2=225292&view=diff
==============================================================================
--- 
webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMTest.java
 (original)
+++ 
webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMTest.java
 Tue Jul 26 05:42:45 2005
@@ -24,8 +24,8 @@
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.attachments.ImageDataSource;
-import org.apache.axis2.attachments.JDK13IO;
+import org.apache.axis2.attachments.utils.ImageDataSource;
+import org.apache.axis2.attachments.utils.JDK13IO;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.description.ServiceDescription;

Modified: 
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMTextImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMTextImpl.java?rev=225292&r1=225291&r2=225292&view=diff
==============================================================================
--- 
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMTextImpl.java
 (original)
+++ 
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMTextImpl.java
 Tue Jul 26 05:42:45 2005
@@ -26,7 +26,7 @@
 
 import org.apache.axis2.attachments.Base64;
 import org.apache.axis2.attachments.ByteArrayDataSource;
-import org.apache.axis2.attachments.IOUtils;
+import org.apache.axis2.attachments.utils.IOUtils;
 import org.apache.axis2.om.OMAttribute;
 import org.apache.axis2.om.OMConstants;
 import org.apache.axis2.om.OMElement;

Modified: 
webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/attachments/ImageSampleTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/attachments/ImageSampleTest.java?rev=225292&r1=225291&r2=225292&view=diff
==============================================================================
--- 
webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/attachments/ImageSampleTest.java
 (original)
+++ 
webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/attachments/ImageSampleTest.java
 Tue Jul 26 05:42:45 2005
@@ -16,6 +16,8 @@
  */
 package org.apache.axis2.attachments;
 
+import org.apache.axis2.attachments.utils.ImageDataSource;
+import org.apache.axis2.attachments.utils.JDK13IO;
 import org.apache.axis2.om.AbstractTestCase;
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.impl.OMOutputImpl;


Reply via email to