依赖架包:
axis.jar、jaxrpc.jar、commons-logging-1.0.4.jar、commons-discovery-0.2.jar、wsdl4j-1.5.1.jar
相关代码:
public final class OutboundQueueSystem {
/**
*
* @param endpoint 接口调用路径
* @param operationName 调用的接口方法名
* @param input 前台请求参数集
* @return
*/
@SuppressWarnings("rawtypes")
public static String outbound(String endpoint,String operationName,Map<String,Object> input){
String result = "";
Service service = new Service();
Call call;
Object[] object = new Object[input.size()];
try {
call = (Call) service.createCall();
call.setTargetEndpointAddress(endpoint);// 远程调用路径
call.setOperationName(operationName);// 调用的方法名
Set<Entry<String, Object>> set = input.entrySet();
int i = 0;
for (Entry entry : set) {
object[i] = entry.getValue().toString();i++;
call.addParameter(entry.getKey().toString(),//参数名
XMLType.XSD_STRING,// 参数类型: String
ParameterMode.IN);// 参数模式:'IN' or 'OUT'
}
call.setReturnType(XMLType.XSD_STRING);// 返回值类型:String
result = (String) call.invoke(object);// 远程调用
} catch (ServiceException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
return result;
}
}