Author: ruwan Date: Sun May 31 13:58:07 2009 New Revision: 37260 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=37260
Log: MTOMSwAClient fixes Modified: branches/synapse/1.3-wso2v1/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java Modified: branches/synapse/1.3-wso2v1/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.3-wso2v1/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java?rev=37260&r1=37259&r2=37260&view=diff ============================================================================== --- branches/synapse/1.3-wso2v1/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java (original) +++ branches/synapse/1.3-wso2v1/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java Sun May 31 13:58:07 2009 @@ -29,8 +29,11 @@ import org.apache.axis2.client.OperationClient; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.Constants; +import org.apache.axis2.AxisFault; import org.apache.axis2.wsdl.WSDLConstants; import org.apache.axis2.context.MessageContext; +import org.apache.axis2.context.ConfigurationContextFactory; +import org.apache.axis2.context.ConfigurationContext; import javax.activation.FileDataSource; import javax.activation.DataHandler; @@ -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"); _______________________________________________ Esb-java-dev mailing list [email protected] https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev
