WebService tool class

import org. apache.axis.client.Call;import org.apache.axis.client.Service;import org.apache.axis.utils.StringUtils;/** * Function description: WebService remote call tool* */public class WebServiceClient {public static void main(String[] args) throws Exception {String url = "http://ip:port/oms/createOrder.service"; String method = "createOrder"; EncryptedUtils encryptedUtils = new EncryptedUtils(); String companyCode = encryptedUtils. encode("test"); String vercode = encryptedUtils.encode("test"); String orderXml = encryptedUtils.encode("test"); String[] parms = new String[]{ companyCode, vercode, orderXml }; WebServiceClient webClient = new WebServiceClient(); String svrResult = webClient.CallMethod(url, method, parms); System.out.println("===========>"+svrResult);} public static String CallMethod( St ring url, String method, Object[] args) {String result = null; if(StringUtils.isEmpty(url)) {return "url address is empty";} if(StringUtils.isEmpty(method)) {return "method address Empty";} Call rpcCall = null; try {//The instance websevice calls the instance Service webService = new Service(); rpcCall = (Call) webService.createCall(); rpcCall.setTargetEndpointAddress(new java.net.URL(url) ); rpcCall.setOperationName(method); //Execute webservice method result = (String) rpcCall.invoke(args);} catch (Exception e) {e.printStackTrace();} return result;}} 

< /pre>

Leave a Comment

Your email address will not be published.