Axis2.0客户端添加base认证

来源:互联网 发布:网络黄牛是什么意思 编辑:程序博客网 时间:2024/06/05 21:51

axis2.0 options 里面的 username password 感觉有点混淆概念,试了半天不是这两个属性,不知道属性放在这里什么用,API很不好找。

        // 服务端引用        EndpointReference targetEPR = new EndpointReference(wsdl);        // 设置属性        Options options = new Options();        options.setTo(targetEPR);        // basic 认证        HttpTransportProperties.Authenticator authenticator = (HttpTransportProperties.Authenticator) options                .getProperty(HTTPConstants.AUTHENTICATE);        if (authenticator == null) {            authenticator = new HttpTransportProperties.Authenticator();            options.setProperty(HTTPConstants.AUTHENTICATE, authenticator);        }        authenticator.setRealm(HttpTransportProperties.Authenticator.BASIC);        authenticator.setUsername("11200005555");        authenticator.setPassword("88888888");        // 设置xml字符集        options.setProperty(org.apache.axis2.Constants.Configuration.CHARACTER_SET_ENCODING, "GBK");        // 设置超时时间        options.setTimeOutInMilliSeconds(20000);


0 0
原创粉丝点击