You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/09/15 21:07:03 UTC
svn commit: r289289 [97/134] - in /webservices/axis2/trunk/java: ./ etc/
modules/addressing/ modules/addressing/src/META-INF/
modules/addressing/src/org/apache/axis2/handlers/addressing/
modules/addressing/test-resources/ modules/addressing/test/org/ap...
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/google/spellcheck/SyncPanel.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/google/spellcheck/SyncPanel.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/google/spellcheck/SyncPanel.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/google/spellcheck/SyncPanel.java Thu Sep 15 11:52:11 2005
@@ -1,89 +1,89 @@
-package sample.google.spellcheck;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-/**
- * class sample.google.spellcheck.SyncPanel
- * This Impements its own GUI of the Synchronous Client and it send the SOAP request after the mouse event.
- *
- * @author Nadana Gunarathna
- */
-public class SyncPanel extends javax.swing.JPanel implements Observer,
- ActionListener {
- FormModel formModel;
- JTextArea writingTextArea;
- JTextArea displayTextArea;
- JTextField errorMessageField;
- JButton sendButton;
-
- public SyncPanel() {
- GridBagLayout gbLayout = new GridBagLayout();
- GridBagConstraints constraint = new GridBagConstraints();
-
-// GridLayout layout = new GridLayout();
-// layout.setColumns(1);
-// layout.setRows(3);
- this.setLayout(gbLayout);
-
- formModel = new FormModel(this);
- writingTextArea = new javax.swing.JTextArea();
- writingTextArea.setLineWrap(true);
-
- displayTextArea = new javax.swing.JTextArea();
- displayTextArea.setLineWrap(true);
- displayTextArea.setEditable(false);
-
- errorMessageField = new JTextField();
- errorMessageField.setEditable(false);
- errorMessageField.setBackground(Color.LIGHT_GRAY);
- errorMessageField.setForeground(Color.RED);
-
- sendButton = new javax.swing.JButton("Send");
- JScrollPane scrollPaneget = new JScrollPane(writingTextArea);
- JScrollPane scrollPaneset = new JScrollPane(displayTextArea);
- writingTextArea.setText("Enter a String");
-
- constraint.fill = GridBagConstraints.BOTH;
- constraint.gridx = 0;
- constraint.weightx = 1;
- constraint.weighty = 8;
- gbLayout.setConstraints(scrollPaneget, constraint);
- this.add(scrollPaneget);
- gbLayout.setConstraints(scrollPaneset, constraint);
- this.add(scrollPaneset);
- constraint.weighty = 1;
- gbLayout.setConstraints(sendButton, constraint);
- this.add(sendButton);
- gbLayout.setConstraints(errorMessageField, constraint);
- this.add(errorMessageField);
-
- sendButton.addActionListener(this);
-
- }
-
- public void update(String suggestion) {
- displayTextArea.setText(suggestion);
- }
-
- //updates the error message to the error message display area
- public void updateError(String message) {
- errorMessageField.setText(message);
- }
-
- public void actionPerformed(ActionEvent e) {
- String str = writingTextArea.getText().trim();
- formModel.doSyncSpellingSuggestion(str);
- }
-
- public void clear() {
- writingTextArea.setText("");
- displayTextArea.setText("");
- errorMessageField.setText("");
- }
-
-}
-
-
+package sample.google.spellcheck;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+/**
+ * class sample.google.spellcheck.SyncPanel
+ * This Impements its own GUI of the Synchronous Client and it send the SOAP request after the mouse event.
+ *
+ * @author Nadana Gunarathna
+ */
+public class SyncPanel extends javax.swing.JPanel implements Observer,
+ ActionListener {
+ FormModel formModel;
+ JTextArea writingTextArea;
+ JTextArea displayTextArea;
+ JTextField errorMessageField;
+ JButton sendButton;
+
+ public SyncPanel() {
+ GridBagLayout gbLayout = new GridBagLayout();
+ GridBagConstraints constraint = new GridBagConstraints();
+
+// GridLayout layout = new GridLayout();
+// layout.setColumns(1);
+// layout.setRows(3);
+ this.setLayout(gbLayout);
+
+ formModel = new FormModel(this);
+ writingTextArea = new javax.swing.JTextArea();
+ writingTextArea.setLineWrap(true);
+
+ displayTextArea = new javax.swing.JTextArea();
+ displayTextArea.setLineWrap(true);
+ displayTextArea.setEditable(false);
+
+ errorMessageField = new JTextField();
+ errorMessageField.setEditable(false);
+ errorMessageField.setBackground(Color.LIGHT_GRAY);
+ errorMessageField.setForeground(Color.RED);
+
+ sendButton = new javax.swing.JButton("Send");
+ JScrollPane scrollPaneget = new JScrollPane(writingTextArea);
+ JScrollPane scrollPaneset = new JScrollPane(displayTextArea);
+ writingTextArea.setText("Enter a String");
+
+ constraint.fill = GridBagConstraints.BOTH;
+ constraint.gridx = 0;
+ constraint.weightx = 1;
+ constraint.weighty = 8;
+ gbLayout.setConstraints(scrollPaneget, constraint);
+ this.add(scrollPaneget);
+ gbLayout.setConstraints(scrollPaneset, constraint);
+ this.add(scrollPaneset);
+ constraint.weighty = 1;
+ gbLayout.setConstraints(sendButton, constraint);
+ this.add(sendButton);
+ gbLayout.setConstraints(errorMessageField, constraint);
+ this.add(errorMessageField);
+
+ sendButton.addActionListener(this);
+
+ }
+
+ public void update(String suggestion) {
+ displayTextArea.setText(suggestion);
+ }
+
+ //updates the error message to the error message display area
+ public void updateError(String message) {
+ errorMessageField.setText(message);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ String str = writingTextArea.getText().trim();
+ formModel.doSyncSpellingSuggestion(str);
+ }
+
+ public void clear() {
+ writingTextArea.setText("");
+ displayTextArea.setText("");
+ errorMessageField.setText("");
+ }
+
+}
+
+
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/google/spellcheck/SyncPanel.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/groovy/GroovyReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/groovy/GroovyReceiver.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/groovy/GroovyReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/groovy/GroovyReceiver.java Thu Sep 15 11:52:11 2005
@@ -1,146 +1,146 @@
-package sample.groovy;
-
-import groovy.lang.GroovyClassLoader;
-import groovy.lang.GroovyObject;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.OperationDescription;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ServiceDescription;
-import org.apache.axis2.engine.MessageReceiver;
-import org.apache.axis2.i18n.Messages;
-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.impl.OMOutputImpl;
-import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
-import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
-import org.apache.axis2.soap.SOAPEnvelope;
-import org.apache.axis2.soap.SOAPFactory;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.StringWriter;
-
-/*
-* 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.
-*
-*
-*/
-
-/**
- * Author : Deepal Jayasinghe
- * Date: Jul 14, 2005
- * Time: 3:13:03 PM
- */
-public class GroovyReceiver
- extends AbstractInOutSyncMessageReceiver
- implements MessageReceiver {
-
- public void invokeBusinessLogic(
- MessageContext inMessage,
- MessageContext outMessage)
- throws AxisFault {
- try {
- ServiceDescription service =
- inMessage
- .getOperationContext()
- .getServiceContext()
- .getServiceConfig();
- Parameter implInfoParam = service.getParameter("ServiceClass");
- if (implInfoParam == null) {
- throw new AxisFault(
- Messages.getMessage("paramIsNotSpecified", "ServiceClass"));
- }
- InputStream groovyFileStream =
- service.getClassLoader().getResourceAsStream(
- implInfoParam.getValue().toString());
-
- if (groovyFileStream == null) {
- throw new AxisFault(
- Messages.getMessage("groovyUnableToLoad", implInfoParam.getValue().toString()));
- }
-
- //look at the method name. if available this should be a groovy method
- OperationDescription op =
- inMessage.getOperationContext().getAxisOperation();
- if (op == null) {
- throw new AxisFault(
- Messages.getMessage("notFound", "Operation"));
- }
- String methodName = op.getName().getLocalPart();
- OMElement firstChild =
- (OMElement) inMessage.getEnvelope().getBody().getFirstChild();
- inMessage.getEnvelope().build();
- StringWriter writer = new StringWriter();
- firstChild.build();
- firstChild.serializeWithCache(
- new OMOutputImpl(
- XMLOutputFactory.newInstance().createXMLStreamWriter(
- writer)));
- writer.flush();
- String value = writer.toString();
- if (value != null) {
- InputStream in = new ByteArrayInputStream(value.getBytes());
- GroovyClassLoader loader = new GroovyClassLoader();
- Class groovyClass = loader.parseClass(groovyFileStream);
- GroovyObject groovyObject =
- (GroovyObject) groovyClass.newInstance();
- Object[] arg = { in };
- Object obj = groovyObject.invokeMethod(methodName, arg);
- if (obj == null) {
- throw new AxisFault(Messages.getMessage("groovyNoanswer"));
- }
-
- SOAPFactory fac = null;
- if(inMessage.isSOAP11()){
- fac = OMAbstractFactory.getSOAP11Factory();
- }else{
- fac = OMAbstractFactory.getSOAP12Factory();
- }
- SOAPEnvelope envelope = fac.getDefaultEnvelope();
- OMNamespace ns =
- fac.createOMNamespace("http://soapenc/", "res");
- OMElement responseElement =
- fac.createOMElement(methodName + "Response", ns);
- String outMessageString = obj.toString();
- // System.out.println("outMessageString = " + outMessageString);
- // responseElement.setText(outMessageString);
- responseElement.addChild(getpayLoad(outMessageString));
- envelope.getBody().addChild(responseElement);
- outMessage.setEnvelope(envelope);
- }
- } catch (Exception e) {
- throw new AxisFault(e);
- }
- }
-
- private OMElement getpayLoad(String str) throws XMLStreamException {
- XMLStreamReader xmlReader =
- XMLInputFactory.newInstance().createXMLStreamReader(
- new ByteArrayInputStream(str.getBytes()));
- OMFactory fac = OMAbstractFactory.getOMFactory();
-
- StAXOMBuilder staxOMBuilder =
- new StAXOMBuilder(fac, xmlReader);
- return staxOMBuilder.getDocumentElement();
- }
-
-}
+package sample.groovy;
+
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyObject;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.OperationDescription;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.ServiceDescription;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.i18n.Messages;
+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.impl.OMOutputImpl;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPFactory;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.StringWriter;
+
+/*
+* 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.
+*
+*
+*/
+
+/**
+ * Author : Deepal Jayasinghe
+ * Date: Jul 14, 2005
+ * Time: 3:13:03 PM
+ */
+public class GroovyReceiver
+ extends AbstractInOutSyncMessageReceiver
+ implements MessageReceiver {
+
+ public void invokeBusinessLogic(
+ MessageContext inMessage,
+ MessageContext outMessage)
+ throws AxisFault {
+ try {
+ ServiceDescription service =
+ inMessage
+ .getOperationContext()
+ .getServiceContext()
+ .getServiceConfig();
+ Parameter implInfoParam = service.getParameter("ServiceClass");
+ if (implInfoParam == null) {
+ throw new AxisFault(
+ Messages.getMessage("paramIsNotSpecified", "ServiceClass"));
+ }
+ InputStream groovyFileStream =
+ service.getClassLoader().getResourceAsStream(
+ implInfoParam.getValue().toString());
+
+ if (groovyFileStream == null) {
+ throw new AxisFault(
+ Messages.getMessage("groovyUnableToLoad", implInfoParam.getValue().toString()));
+ }
+
+ //look at the method name. if available this should be a groovy method
+ OperationDescription op =
+ inMessage.getOperationContext().getAxisOperation();
+ if (op == null) {
+ throw new AxisFault(
+ Messages.getMessage("notFound", "Operation"));
+ }
+ String methodName = op.getName().getLocalPart();
+ OMElement firstChild =
+ (OMElement) inMessage.getEnvelope().getBody().getFirstChild();
+ inMessage.getEnvelope().build();
+ StringWriter writer = new StringWriter();
+ firstChild.build();
+ firstChild.serializeWithCache(
+ new OMOutputImpl(
+ XMLOutputFactory.newInstance().createXMLStreamWriter(
+ writer)));
+ writer.flush();
+ String value = writer.toString();
+ if (value != null) {
+ InputStream in = new ByteArrayInputStream(value.getBytes());
+ GroovyClassLoader loader = new GroovyClassLoader();
+ Class groovyClass = loader.parseClass(groovyFileStream);
+ GroovyObject groovyObject =
+ (GroovyObject) groovyClass.newInstance();
+ Object[] arg = { in };
+ Object obj = groovyObject.invokeMethod(methodName, arg);
+ if (obj == null) {
+ throw new AxisFault(Messages.getMessage("groovyNoanswer"));
+ }
+
+ SOAPFactory fac = null;
+ if(inMessage.isSOAP11()){
+ fac = OMAbstractFactory.getSOAP11Factory();
+ }else{
+ fac = OMAbstractFactory.getSOAP12Factory();
+ }
+ SOAPEnvelope envelope = fac.getDefaultEnvelope();
+ OMNamespace ns =
+ fac.createOMNamespace("http://soapenc/", "res");
+ OMElement responseElement =
+ fac.createOMElement(methodName + "Response", ns);
+ String outMessageString = obj.toString();
+ // System.out.println("outMessageString = " + outMessageString);
+ // responseElement.setText(outMessageString);
+ responseElement.addChild(getpayLoad(outMessageString));
+ envelope.getBody().addChild(responseElement);
+ outMessage.setEnvelope(envelope);
+ }
+ } catch (Exception e) {
+ throw new AxisFault(e);
+ }
+ }
+
+ private OMElement getpayLoad(String str) throws XMLStreamException {
+ XMLStreamReader xmlReader =
+ XMLInputFactory.newInstance().createXMLStreamReader(
+ new ByteArrayInputStream(str.getBytes()));
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+
+ StAXOMBuilder staxOMBuilder =
+ new StAXOMBuilder(fac, xmlReader);
+ return staxOMBuilder.getDocumentElement();
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/groovy/GroovyReceiver.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/groovy/META-INF/service.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/groovy/META-INF/service.xml?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/groovy/META-INF/service.xml (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/groovy/META-INF/service.xml Thu Sep 15 11:52:11 2005
@@ -1,12 +1,12 @@
-<service name="GroovyService">
- <description>
- This is Groovy service , what this really does is take the incoming SOAP message
- and hand that over to Groovy class and which process the message and return a SOAP
- message back to MessageReceiver
- </description>
- <parameter name="ServiceClass" locked="false">GroovyRcv.groovy</parameter>
-
- <operation name="echo">
- <messageReceiver class="sample.groovy.GroovyReceiver"/>
- </operation>
+<service name="GroovyService">
+ <description>
+ This is Groovy service , what this really does is take the incoming SOAP message
+ and hand that over to Groovy class and which process the message and return a SOAP
+ message back to MessageReceiver
+ </description>
+ <parameter name="ServiceClass" locked="false">GroovyRcv.groovy</parameter>
+
+ <operation name="echo">
+ <messageReceiver class="sample.groovy.GroovyReceiver"/>
+ </operation>
</service>
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/groovy/META-INF/service.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClient.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClient.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClient.java Thu Sep 15 11:52:11 2005
@@ -1,39 +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.imagetransfer.client;
-
-import javax.swing.*;
-import java.awt.*;
-
-public class MTOMClient extends JFrame {
-
- public MTOMClient(String title) throws HeadlessException {
- super(title);
-
- this.getContentPane().add(new UserInterface(this));
- this.show();
- }
-
- public static void main(String[] args) {
- MTOMClient form = new MTOMClient("MTOM Sample 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();
- }
-}
+/*
+ * 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.imagetransfer.client;
+
+import javax.swing.*;
+import java.awt.*;
+
+public class MTOMClient extends JFrame {
+
+ public MTOMClient(String title) throws HeadlessException {
+ super(title);
+
+ this.getContentPane().add(new UserInterface(this));
+ this.show();
+ }
+
+ public static void main(String[] args) {
+ MTOMClient form = new MTOMClient("MTOM Sample 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/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClient.java
------------------------------------------------------------------------------
svn:eol-style = native
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=289289&r1=289288&r2=289289&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 Thu Sep 15 11:52:11 2005
@@ -1,107 +1,107 @@
-/*
- * 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.imagetransfer.client;
-
-import java.awt.Image;
-import java.io.File;
-import java.io.FileInputStream;
-
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.attachments.utils.ImageDataSource;
-import org.apache.axis2.attachments.utils.ImageIO;
-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;
-import org.apache.axis2.soap.SOAP11Constants;
-
-
-public class MTOMClientModel {
- private File inputFile = null;
-
- private EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:8080/axis2/services/MyService");
-
- private QName operationName = new QName("mtomSample");
-
-
- public MTOMClientModel() {
-
- }
-
- private OMElement createEnvelope(String fileName) throws Exception {
-
- DataHandler expectedDH;
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
-
- OMElement data = fac.createOMElement("mtomSample", omNs);
- OMElement image = fac.createOMElement("image", omNs);
- Image expectedImage;
- expectedImage = new ImageIO()
- .loadImage(new FileInputStream(inputFile));
-
- ImageDataSource dataSource = new ImageDataSource("test.jpg",
- expectedImage);
- expectedDH = new DataHandler(dataSource);
- OMText textData = fac.createText(expectedDH, true);
- image.addChild(textData);
-
- OMElement imageName = fac.createOMElement("fileName", omNs);
- if (fileName != null) {
- imageName.setText(fileName);
- }
- //OMElement wrap = fac.createOMElement("wrap",omNs);
- data.addChild(image);
- data.addChild(imageName);
- //data.addChild(wrap);
- return data;
-
- }
-
- public OMElement sendFile(String fileName) throws Exception {
-
- OMElement payload = createEnvelope(fileName);
-
- Call call = new Call();
- call.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
- call.setTo(targetEPR);
- // enabling MTOM in the client side
- call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
- call.setTransportInfo(Constants.TRANSPORT_HTTP,
- Constants.TRANSPORT_HTTP, false);
- return call.invokeBlocking(operationName
- .getLocalPart(),
- payload);
-
- }
-
-
- public void setTargetEPR(String targetEPR) {
- this.targetEPR = new EndpointReference(targetEPR);
-
- }
-
-
- public void setInputFile(File inputFile) {
- this.inputFile = inputFile;
- }
-}
+/*
+ * 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.imagetransfer.client;
+
+import java.awt.Image;
+import java.io.File;
+import java.io.FileInputStream;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.attachments.utils.ImageDataSource;
+import org.apache.axis2.attachments.utils.ImageIO;
+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;
+import org.apache.axis2.soap.SOAP11Constants;
+
+
+public class MTOMClientModel {
+ private File inputFile = null;
+
+ private EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:8080/axis2/services/MyService");
+
+ private QName operationName = new QName("mtomSample");
+
+
+ public MTOMClientModel() {
+
+ }
+
+ private OMElement createEnvelope(String fileName) throws Exception {
+
+ DataHandler expectedDH;
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
+
+ OMElement data = fac.createOMElement("mtomSample", omNs);
+ OMElement image = fac.createOMElement("image", omNs);
+ Image expectedImage;
+ expectedImage = new ImageIO()
+ .loadImage(new FileInputStream(inputFile));
+
+ ImageDataSource dataSource = new ImageDataSource("test.jpg",
+ expectedImage);
+ expectedDH = new DataHandler(dataSource);
+ OMText textData = fac.createText(expectedDH, true);
+ image.addChild(textData);
+
+ OMElement imageName = fac.createOMElement("fileName", omNs);
+ if (fileName != null) {
+ imageName.setText(fileName);
+ }
+ //OMElement wrap = fac.createOMElement("wrap",omNs);
+ data.addChild(image);
+ data.addChild(imageName);
+ //data.addChild(wrap);
+ return data;
+
+ }
+
+ public OMElement sendFile(String fileName) throws Exception {
+
+ OMElement payload = createEnvelope(fileName);
+
+ Call call = new Call();
+ call.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ call.setTo(targetEPR);
+ // enabling MTOM in the client side
+ call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
+ call.setTransportInfo(Constants.TRANSPORT_HTTP,
+ Constants.TRANSPORT_HTTP, false);
+ return call.invokeBlocking(operationName
+ .getLocalPart(),
+ payload);
+
+ }
+
+
+ public void setTargetEPR(String targetEPR) {
+ this.targetEPR = new EndpointReference(targetEPR);
+
+ }
+
+
+ public void setInputFile(File inputFile) {
+ this.inputFile = inputFile;
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClientModel.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/UserInterface.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/UserInterface.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/UserInterface.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/UserInterface.java Thu Sep 15 11:52:11 2005
@@ -1,204 +1,204 @@
-/*
- * 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.imagetransfer.client;
-
-import org.apache.axis2.om.OMElement;
-
-import javax.swing.*;
-import javax.swing.filechooser.FileFilter;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.File;
-
-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 deriredFileName = null;
-
- private String EPRName = null;
-
- private MTOMClient parent;
-
- public UserInterface(MTOMClient 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.addChoosableFileFilter(new ImageFilter());
- jFileChooser.setAcceptAllFileFilterUsed(false);
- jFileChooser.setName("Image Chosser");
- this.browse = new JButton("Browse");
- this.send = new JButton("Send The Image");
- 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/MTOMService");
-
- 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 Image to Send");
-
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- file = jFileChooser.getSelectedFile();
- if (file.getAbsolutePath() != null) {
- fileFeild.setText(file.getAbsolutePath());
- }
- } else {
-
- }
-
- jFileChooser.setSelectedFile(null);
-
- }
- if (e.getSource() == send) {
- if (fileName.getText() != null) {
- deriredFileName = 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(deriredFileName);
- }
-
- }
- }
-
- public void send(String fileName) {
-
- MTOMClientModel mtomTest = new MTOMClientModel();
-
- try {
- mtomTest.setInputFile(file);
- mtomTest.setTargetEPR(EPRName);
- OMElement result = mtomTest.sendFile(fileName);
- jTextArea.setText(result.toString());
- jTextArea.append("\n"+result.getText());
- if (result.getText().equalsIgnoreCase("Image Saved"))
- {
- JOptionPane.showMessageDialog(parent, "Sent & saved Image Succesfully",
- " Success", JOptionPane.PLAIN_MESSAGE);
- }
- } catch (Exception e) {
- e.printStackTrace(); //To change body of catch statement use File |
- // Settings | File Templates.
- }
-
- }
-
- class ImageFilter extends FileFilter {
-
- //Accept all directories and all gif, jpg, tiff, or png files.
- public boolean accept(File f) {
- if (f.isDirectory()) {
- return true;
- }
-
- String extension = getExtension(f);
- if (extension != null) {
- return extension.equals("jpg") || extension.equals("JPEG");
- }
-
- return false;
- }
-
- public String getDescription() {
- return null; //To change body of implemented methods use File |
- // Settings | File Templates.
- }
-
- private String getExtension(File f) {
- String ext = null;
- String s = f.getName();
- int i = s.lastIndexOf('.');
-
- if (i > 0 && i < s.length() - 1) {
- ext = s.substring(i + 1).toLowerCase();
- }
- return ext;
- }
-
- }
-
- //The description of this filter
- public String getDescription() {
- return "Just Images";
- }
-
+/*
+ * 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.imagetransfer.client;
+
+import org.apache.axis2.om.OMElement;
+
+import javax.swing.*;
+import javax.swing.filechooser.FileFilter;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+
+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 deriredFileName = null;
+
+ private String EPRName = null;
+
+ private MTOMClient parent;
+
+ public UserInterface(MTOMClient 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.addChoosableFileFilter(new ImageFilter());
+ jFileChooser.setAcceptAllFileFilterUsed(false);
+ jFileChooser.setName("Image Chosser");
+ this.browse = new JButton("Browse");
+ this.send = new JButton("Send The Image");
+ 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/MTOMService");
+
+ 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 Image to Send");
+
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ file = jFileChooser.getSelectedFile();
+ if (file.getAbsolutePath() != null) {
+ fileFeild.setText(file.getAbsolutePath());
+ }
+ } else {
+
+ }
+
+ jFileChooser.setSelectedFile(null);
+
+ }
+ if (e.getSource() == send) {
+ if (fileName.getText() != null) {
+ deriredFileName = 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(deriredFileName);
+ }
+
+ }
+ }
+
+ public void send(String fileName) {
+
+ MTOMClientModel mtomTest = new MTOMClientModel();
+
+ try {
+ mtomTest.setInputFile(file);
+ mtomTest.setTargetEPR(EPRName);
+ OMElement result = mtomTest.sendFile(fileName);
+ jTextArea.setText(result.toString());
+ jTextArea.append("\n"+result.getText());
+ if (result.getText().equalsIgnoreCase("Image Saved"))
+ {
+ JOptionPane.showMessageDialog(parent, "Sent & saved Image Succesfully",
+ " Success", JOptionPane.PLAIN_MESSAGE);
+ }
+ } catch (Exception e) {
+ e.printStackTrace(); //To change body of catch statement use File |
+ // Settings | File Templates.
+ }
+
+ }
+
+ class ImageFilter extends FileFilter {
+
+ //Accept all directories and all gif, jpg, tiff, or png files.
+ public boolean accept(File f) {
+ if (f.isDirectory()) {
+ return true;
+ }
+
+ String extension = getExtension(f);
+ if (extension != null) {
+ return extension.equals("jpg") || extension.equals("JPEG");
+ }
+
+ return false;
+ }
+
+ public String getDescription() {
+ return null; //To change body of implemented methods use File |
+ // Settings | File Templates.
+ }
+
+ private String getExtension(File f) {
+ String ext = null;
+ String s = f.getName();
+ int i = s.lastIndexOf('.');
+
+ if (i > 0 && i < s.length() - 1) {
+ ext = s.substring(i + 1).toLowerCase();
+ }
+ return ext;
+ }
+
+ }
+
+ //The description of this filter
+ public String getDescription() {
+ return "Just Images";
+ }
+
}
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/UserInterface.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/META-INF/service.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/META-INF/service.xml?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/META-INF/service.xml (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/META-INF/service.xml Thu Sep 15 11:52:11 2005
@@ -1,9 +1,9 @@
-<service name="MTOMService">
- <description>
- This is a sample Web Service for illustrating MTOM based binary data transfer.
- </description>
- <parameter name="ServiceClass" locked="false">sample.mtom.imagetransfer.service.MTOMService</parameter>
- <operation name="mtomSample">
- <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
- </operation>
+<service name="MTOMService">
+ <description>
+ This is a sample Web Service for illustrating MTOM based binary data transfer.
+ </description>
+ <parameter name="ServiceClass" locked="false">sample.mtom.imagetransfer.service.MTOMService</parameter>
+ <operation name="mtomSample">
+ <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ </operation>
</service>
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/META-INF/service.xml
------------------------------------------------------------------------------
svn:eol-style = native
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=289289&r1=289288&r2=289289&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 Thu Sep 15 11:52:11 2005
@@ -1,49 +1,49 @@
-/*
- * 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.imagetransfer.service;
-
-import org.apache.axis2.attachments.utils.ImageIO;
-import org.apache.axis2.om.*;
-
-import javax.activation.DataHandler;
-import java.awt.*;
-import java.io.FileOutputStream;
-
-/**
- * @author <a href="mailto:thilina@opensource.lk">Thilina Gunarathne </a>
- */
-public class MTOMService {
- public OMElement mtomSample(OMElement element) throws Exception {
-
- OMElement imageEle = element.getFirstElement();
- OMElement imageName = (OMElement) imageEle.getNextSibling();
- OMText binaryNode = (OMText) imageEle.getFirstChild();
- String fileName = imageName.getText();
- //Extracting the data and saving
- DataHandler actualDH;
- actualDH = binaryNode.getDataHandler();
- Image actualObject = new ImageIO().loadImage(actualDH.getDataSource()
- .getInputStream());
- FileOutputStream imageOutStream = new FileOutputStream(fileName);
- new ImageIO().saveImage("image/jpeg", actualObject, imageOutStream);
- //setting response
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace ns = fac.createOMNamespace("urn://fakenamespace", "ns");
- OMElement ele = fac.createOMElement("response", ns);
- ele.setText("Image Saved");
- return ele;
- }
+/*
+ * 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.imagetransfer.service;
+
+import org.apache.axis2.attachments.utils.ImageIO;
+import org.apache.axis2.om.*;
+
+import javax.activation.DataHandler;
+import java.awt.*;
+import java.io.FileOutputStream;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk">Thilina Gunarathne </a>
+ */
+public class MTOMService {
+ public OMElement mtomSample(OMElement element) throws Exception {
+
+ OMElement imageEle = element.getFirstElement();
+ OMElement imageName = (OMElement) imageEle.getNextSibling();
+ OMText binaryNode = (OMText) imageEle.getFirstChild();
+ String fileName = imageName.getText();
+ //Extracting the data and saving
+ DataHandler actualDH;
+ actualDH = binaryNode.getDataHandler();
+ Image actualObject = new ImageIO().loadImage(actualDH.getDataSource()
+ .getInputStream());
+ FileOutputStream imageOutStream = new FileOutputStream(fileName);
+ new ImageIO().saveImage("image/jpeg", actualObject, imageOutStream);
+ //setting response
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace ns = fac.createOMNamespace("urn://fakenamespace", "ns");
+ OMElement ele = fac.createOMElement("response", ns);
+ ele.setText("Image Saved");
+ return ele;
+ }
}
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/MTOMService.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClient.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClient.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClient.java Thu Sep 15 11:52:11 2005
@@ -1,39 +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();
- }
-}
+/*
+ * 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/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClient.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClientModel.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClientModel.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClientModel.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClientModel.java Thu Sep 15 11:52:11 2005
@@ -1,75 +1,75 @@
-/*
- * 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 org.apache.axis2.Constants;
-import org.apache.axis2.soap.SOAP12Constants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.clientapi.Call;
-import org.apache.axis2.om.*;
-
-import javax.activation.DataHandler;
-import javax.activation.FileDataSource;
-import javax.xml.namespace.QName;
-import java.io.File;
-
-
-public class InteropClientModel {
- private File inputFile = null;
-
- private EndpointReference targetEPR = new EndpointReference("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.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
- call.setTo(targetEPR);
- // enabling MTOM in the client side
- call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_FALSE);
- call.setTransportInfo(Constants.TRANSPORT_HTTP,
- Constants.TRANSPORT_HTTP, false);
- return call.invokeBlocking(operationName
- .getLocalPart(),
- payload);
- }
-
- public void setTargetEPR(String targetEPR) {
- this.targetEPR = new EndpointReference(targetEPR);
- }
-}
+/*
+ * 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 org.apache.axis2.Constants;
+import org.apache.axis2.soap.SOAP12Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.clientapi.Call;
+import org.apache.axis2.om.*;
+
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+import javax.xml.namespace.QName;
+import java.io.File;
+
+
+public class InteropClientModel {
+ private File inputFile = null;
+
+ private EndpointReference targetEPR = new EndpointReference("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.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ call.setTo(targetEPR);
+ // enabling MTOM in the client side
+ call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_FALSE);
+ call.setTransportInfo(Constants.TRANSPORT_HTTP,
+ Constants.TRANSPORT_HTTP, false);
+ return call.invokeBlocking(operationName
+ .getLocalPart(),
+ payload);
+ }
+
+ public void setTargetEPR(String targetEPR) {
+ this.targetEPR = new EndpointReference(targetEPR);
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/InteropClientModel.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/UserInterface.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/UserInterface.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/UserInterface.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/UserInterface.java Thu Sep 15 11:52:11 2005
@@ -1,152 +1,152 @@
-/*
- * 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 org.apache.axis2.om.OMElement;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.File;
-
-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 = 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();
- }
-
- }
+/*
+ * 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 org.apache.axis2.om.OMElement;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+
+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 = 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();
+ }
+
+ }
}
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/client/UserInterface.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/service/META-INF/service.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/service/META-INF/service.xml?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/service/META-INF/service.xml (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/service/META-INF/service.xml Thu Sep 15 11:52:11 2005
@@ -1,9 +1,9 @@
-<service name="MTOMService">
- <description>
- This is a sample Web Service with two operations,echo and ping.
- </description>
- <parameter name="ServiceClass" locked="false">sample.mtom.interop.service.interopService</parameter>
- <operation name="interopService">
- <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
- </operation>
+<service name="MTOMService">
+ <description>
+ This is a sample Web Service with two operations,echo and ping.
+ </description>
+ <parameter name="ServiceClass" locked="false">sample.mtom.interop.service.interopService</parameter>
+ <operation name="interopService">
+ <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ </operation>
</service>
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/service/META-INF/service.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/interop/service/interopService.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/om/binary/FIUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/om/binary/FIUtil.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/om/binary/FIUtil.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/om/binary/FIUtil.java Thu Sep 15 11:52:11 2005
@@ -1,125 +1,125 @@
-package sample.om.binary;
-
-import com.sun.xml.fastinfoset.stax.StAXDocumentParser;
-import com.sun.xml.fastinfoset.stax.StAXDocumentSerializer;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.impl.OMOutputImpl;
-import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.*;
-
-/*
- * Copyright 2001-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.
- *
- * @author : Eran Chinthaka (chinthaka@apache.org)
- */
-
-public class FIUtil {
-
- public File getBinaryXML(String inFileName) {
- try {
- XMLToFastInfosetSAXSerializer docSerializer = new XMLToFastInfosetSAXSerializer();
- //XML input file, such as ./data/inv100.xml
- File input = new File(inFileName);
- //FastInfoset output file, such as ./data/inv100_sax.finf.
- String finf = getFinfFilename(inFileName);
- File ouput = new File(finf);
- docSerializer.write(input, ouput);
- return ouput;
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
- public XMLStreamReader getEventReaderFromBinaryFile(File binaryFile) {
- InputStream document = null;
- try {
- document = new BufferedInputStream(new FileInputStream(binaryFile));
- return new StAXDocumentParser(document);
- } catch (FileNotFoundException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
-
- return null;
- }
-
- private static String getFinfFilename(String xmlFilename) {
- int ext = xmlFilename.lastIndexOf(".");
- return xmlFilename.substring(0, ext) + ".finf";
- }
-
- public void testReadBinaryToOMAndSerialize() {
- String inFileName = "resources/om/binary/binary.xml";
-
-// FIUtil fiUtil = new FIUtil();
-// File binaryXML = fiUtil.getBinaryXML(inFileName);
-// System.out.println("Created binary file " + binaryXML.getName() + " from " + inFileName + "......");
-
-
- try {
- System.out.println("********** XML ==> OM **************");
- XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(inFileName));
- StAXOMBuilder omStAXOMBuilder = new StAXOMBuilder(xmlStreamReader);
- omStAXOMBuilder.setDoDebug(true);
- System.out.println("StAXOMBuilder created from " + inFileName + " ........");
-
- System.out.println("********** OM ==> Binary **************");
- File binaryFile = getBinaryXML(inFileName);
- StAXDocumentSerializer binaryStAXSerializer = new StAXDocumentSerializer(new FileOutputStream(binaryFile));
- omStAXOMBuilder.getDocumentElement().build();
- omStAXOMBuilder.getDocumentElement().serializeWithCache(binaryStAXSerializer);
-// binaryStAXSerializer.flush();
- System.out.println("Created binary file " + binaryFile.getName() + " from OM ......");
-
- System.out.println("********** Binary ==> OM **************");
- XMLStreamReader eventReaderFromBinaryFile = getEventReaderFromBinaryFile(binaryFile);
- System.out.println("Created XMLStreamReader from the binary file .....");
-
- StAXOMBuilder builder = new StAXOMBuilder(eventReaderFromBinaryFile);
- System.out.println("StAXOMBuilder created from the given event reader ....");
-
- OMElement documentElement = builder.getDocumentElement();
- documentElement.build();
-
- System.out.println("********** OM ==> XML **************");
- OMOutputImpl output = new OMOutputImpl(System.out, false);
- documentElement.serialize(output);
- output.flush();
-
- } catch (XMLStreamException e) {
- throw new UnsupportedOperationException();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- throw new UnsupportedOperationException();
- } catch (IOException e) {
- throw new UnsupportedOperationException();
- }
-
-
- }
-
- public static void main(String[] args) {
- FIUtil util = new FIUtil();
- util.testReadBinaryToOMAndSerialize();
- }
-
-
-}
-
+package sample.om.binary;
+
+import com.sun.xml.fastinfoset.stax.StAXDocumentParser;
+import com.sun.xml.fastinfoset.stax.StAXDocumentSerializer;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.*;
+
+/*
+ * Copyright 2001-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.
+ *
+ * @author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class FIUtil {
+
+ public File getBinaryXML(String inFileName) {
+ try {
+ XMLToFastInfosetSAXSerializer docSerializer = new XMLToFastInfosetSAXSerializer();
+ //XML input file, such as ./data/inv100.xml
+ File input = new File(inFileName);
+ //FastInfoset output file, such as ./data/inv100_sax.finf.
+ String finf = getFinfFilename(inFileName);
+ File ouput = new File(finf);
+ docSerializer.write(input, ouput);
+ return ouput;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ public XMLStreamReader getEventReaderFromBinaryFile(File binaryFile) {
+ InputStream document = null;
+ try {
+ document = new BufferedInputStream(new FileInputStream(binaryFile));
+ return new StAXDocumentParser(document);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ return null;
+ }
+
+ private static String getFinfFilename(String xmlFilename) {
+ int ext = xmlFilename.lastIndexOf(".");
+ return xmlFilename.substring(0, ext) + ".finf";
+ }
+
+ public void testReadBinaryToOMAndSerialize() {
+ String inFileName = "resources/om/binary/binary.xml";
+
+// FIUtil fiUtil = new FIUtil();
+// File binaryXML = fiUtil.getBinaryXML(inFileName);
+// System.out.println("Created binary file " + binaryXML.getName() + " from " + inFileName + "......");
+
+
+ try {
+ System.out.println("********** XML ==> OM **************");
+ XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(inFileName));
+ StAXOMBuilder omStAXOMBuilder = new StAXOMBuilder(xmlStreamReader);
+ omStAXOMBuilder.setDoDebug(true);
+ System.out.println("StAXOMBuilder created from " + inFileName + " ........");
+
+ System.out.println("********** OM ==> Binary **************");
+ File binaryFile = getBinaryXML(inFileName);
+ StAXDocumentSerializer binaryStAXSerializer = new StAXDocumentSerializer(new FileOutputStream(binaryFile));
+ omStAXOMBuilder.getDocumentElement().build();
+ omStAXOMBuilder.getDocumentElement().serializeWithCache(binaryStAXSerializer);
+// binaryStAXSerializer.flush();
+ System.out.println("Created binary file " + binaryFile.getName() + " from OM ......");
+
+ System.out.println("********** Binary ==> OM **************");
+ XMLStreamReader eventReaderFromBinaryFile = getEventReaderFromBinaryFile(binaryFile);
+ System.out.println("Created XMLStreamReader from the binary file .....");
+
+ StAXOMBuilder builder = new StAXOMBuilder(eventReaderFromBinaryFile);
+ System.out.println("StAXOMBuilder created from the given event reader ....");
+
+ OMElement documentElement = builder.getDocumentElement();
+ documentElement.build();
+
+ System.out.println("********** OM ==> XML **************");
+ OMOutputImpl output = new OMOutputImpl(System.out, false);
+ documentElement.serialize(output);
+ output.flush();
+
+ } catch (XMLStreamException e) {
+ throw new UnsupportedOperationException();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ throw new UnsupportedOperationException();
+ } catch (IOException e) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ }
+
+ public static void main(String[] args) {
+ FIUtil util = new FIUtil();
+ util.testReadBinaryToOMAndSerialize();
+ }
+
+
+}
+
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/om/binary/FIUtil.java
------------------------------------------------------------------------------
svn:eol-style = native