webservice客户端调用

public static void main(String[] args) {
        try {
            String endpoint = "http://1.1.1.1:8080/cms/services/ICommonService?wsdl";
            // 直接引用远程的wsdl文件
            // 以下都是套路
            Service service = new Service();
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(endpoint);
            // WSDL里面描述的接口名称
            call.setOperationName("serviceHb");
            // 接口的参数
            call.addParameter("nodeIndexCode",XMLType.XSD_STRING,ParameterMode.IN);
            // 设置返回类型
            call.setReturnType(XMLType.XSD_STRING);
            String temp = "测试人员";
            QName qName=new QName("http://ws.cms.is6.hk.com","serviceHb");
            String result = (String) call.invoke(qName, new Object[] {temp});
            // 给方法传递参数,并且调用方法
            System.out.println("result is " + result);
        } catch (Exception e) {
            System.err.println(e.toString());
        }
    }

原文地址:https://www.cnblogs.com/yangxiong/p/8422612.html