You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ch...@apache.org on 2006/08/03 19:14:04 UTC

svn commit: r428455 - in /webservices/sandesha/trunk/java/samples: conf/userguide/services.xml src/sandesha2/samples/userguide/RMSampleService.java

Author: chamikara
Date: Thu Aug  3 10:14:03 2006
New Revision: 428455

URL: http://svn.apache.org/viewvc?rev=428455&view=rev
Log:
Added the MTOMPing operation to the RMSampleService

Modified:
    webservices/sandesha/trunk/java/samples/conf/userguide/services.xml
    webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/RMSampleService.java

Modified: webservices/sandesha/trunk/java/samples/conf/userguide/services.xml
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/samples/conf/userguide/services.xml?rev=428455&r1=428454&r2=428455&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/samples/conf/userguide/services.xml (original)
+++ webservices/sandesha/trunk/java/samples/conf/userguide/services.xml Thu Aug  3 10:14:03 2006
@@ -13,6 +13,10 @@
         <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver" />
     </operation>
     
+    <operation name="MTOMPing" mep="http://www.w3.org/2004/08/wsdl/in-only">  
+        <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver" />
+    </operation>
+    
     <operation name="echoString">
         <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />
     </operation>
@@ -23,9 +27,8 @@
 		xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
 	    xmlns:wsrm="http://ws.apache.org/sandesha2/policy" wsu:Id="RMPolicy">
 	        
-	      <!-- Following policy value has been overrided from the default values.-->> 
-	      <wsrm:AcknowledgementInterval>3500</wsrm:AcknowledgementInterval>
-	    
+	    <!-- Following policy value has been overrided from the default values.-->> 
+	    <wsrm:AcknowledgementInterval>3500</wsrm:AcknowledgementInterval>
 	   
 	</wsp:Policy>
     

Modified: webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/RMSampleService.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/RMSampleService.java?rev=428455&r1=428454&r2=428455&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/RMSampleService.java (original)
+++ webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/RMSampleService.java Thu Aug  3 10:14:03 2006
@@ -17,15 +17,21 @@
 
 package sandesha2.samples.userguide;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.activation.DataHandler;
 import javax.xml.namespace.QName;
 
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMText;
+import org.apache.axis2.AxisFault;
 
 public class RMSampleService {
 
@@ -35,7 +41,9 @@
 	private final String Sequence = "Sequence";
 	private final String echoStringResponse = "echoStringResponse";
 	private final String EchoStringReturn = "EchoStringReturn";
-  
+	private final String Attachment = "Attachment";
+	private final String DESTINATION_IMAGE_FILE = "mtom-image1.jpg";
+	
 	public OMElement echoString(OMElement in) throws Exception {
 		
 		OMElement textElem = in.getFirstChildWithName(new QName (applicationNamespaceName,Text));
@@ -75,5 +83,34 @@
 		String textValue = textElem.getText();
 		
 		System.out.println("ping service got text:" + textValue);
+	}
+	
+	public void MTOMPing(OMElement in) throws Exception  {
+		OMElement attachmentElem = in.getFirstChildWithName(new QName(applicationNamespaceName, Attachment));
+		if (attachmentElem == null)
+			throw new AxisFault("'Attachment' element is not present as a child of the 'Ping' element");
+
+		OMText binaryElem = (OMText) attachmentElem.getFirstOMChild();
+
+		binaryElem.setOptimize(true);
+		DataHandler dataHandler = (DataHandler) binaryElem.getDataHandler();
+
+		try {
+			
+			File destinationFile = new File(DESTINATION_IMAGE_FILE);
+			if (destinationFile.exists())
+				destinationFile.delete();
+
+			FileOutputStream fileOutputStream = new FileOutputStream(DESTINATION_IMAGE_FILE);
+
+			InputStream inputStream = dataHandler.getDataSource().getInputStream();
+			byte[] bytes = new byte[5000];
+			int length = inputStream.read(bytes);
+			fileOutputStream.write(bytes, 0, length);
+			fileOutputStream.close();
+
+		} catch (Exception e) {
+			throw new AxisFault(e);
+		}
 	}
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org