Java使用axis2调用wsdl形式的webservice

来源:互联网 发布:罗伯托.贝尼尼 知乎 编辑:程序博客网 时间:2024/06/06 00:51

依赖架包:
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;    }}
0 0
原创粉丝点击