You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ve...@apache.org on 2009/05/31 20:37:36 UTC

svn commit: r780495 - /synapse/trunk/java/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java

Author: veithen
Date: Sun May 31 18:37:36 2009
New Revision: 780495

URL: http://svn.apache.org/viewvc?rev=780495&view=rev
Log:
Fixed MTOMSwAClient (sample 51).

Modified:
    synapse/trunk/java/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java

Modified: synapse/trunk/java/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java?rev=780495&r1=780494&r2=780495&view=diff
==============================================================================
--- synapse/trunk/java/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java (original)
+++ synapse/trunk/java/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java Sun May 31 18:37:36 2009
@@ -28,8 +28,11 @@
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.OperationClient;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.context.MessageContext;
 
 import javax.activation.FileDataSource;
@@ -49,6 +52,19 @@
         return result;
     }
 
+    private static ServiceClient createServiceClient() throws AxisFault {
+        String repo = getProperty("repository", "client_repo");
+        if (repo != null && !"null".equals(repo)) {
+            ConfigurationContext configContext =
+                    ConfigurationContextFactory.
+                            createConfigurationContextFromFileSystem(repo,
+                                    repo + File.separator + "conf" + File.separator + "axis2.xml");
+            return new ServiceClient(configContext, null);
+        } else {
+            return new ServiceClient();
+        }
+    }
+
     public static void main(String[] args) throws Exception {
 
         String targetEPR = getProperty("opt_url", "http://localhost:8280/services/MTOMSwASampleService");
@@ -67,6 +83,7 @@
 
         // let the server read the stream before exit
         Thread.sleep(1000);
+        System.exit(0);
     }
 
     public static MessageContext sendUsingSwA(String fileName, String targetEPR) throws IOException {
@@ -76,7 +93,7 @@
         options.setAction("urn:uploadFileUsingSwA");
         options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);
 
-        ServiceClient sender = new ServiceClient();
+        ServiceClient sender = createServiceClient();
         sender.setOptions(options);
         OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
 
@@ -139,7 +156,7 @@
         request.addChild(image);
         payload.addChild(request);
 
-        ServiceClient serviceClient = new ServiceClient();
+        ServiceClient serviceClient = createServiceClient();
         Options options = new Options();
         options.setTo(new EndpointReference(targetEPR));
         options.setAction("urn:uploadFileUsingMTOM");