java - org.apache.axis2.AxisFault :Transport error: 407 Error:Proxy Authentication Required

标签 java web-services authentication apache-axis

这是我的代码..我正在尝试使用 .asmx?WSDL Web 服务。

错误: org.apache.axis2.AxisFault:传输错误:407 错误:需要代理身份验证

    package org.tempuri;


    import org.apache.axis2.AxisFault;
    import org.tempuri.ServiceStub.Get_All_Pendancy_List;
    import org.tempuri.ServiceStub.Get_All_Pendancy_ListResponse;



    public class TestClient {

        /**
         * @param args
         */
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            try {

                //

                //

                //Proxy Settings

                System.getProperties().put("http.proxyHost", "111.11.11.11");
                System.getProperties().put("http.proxyPort", "1111");
                System.getProperties().put("http.proxyUser", "11111");
                System.getProperties().put("http.proxyPassword", "SaK@11111");


                ServiceStub serviceStub = new ServiceStub();
                Get_All_Pendancy_List gpl = new Get_All_Pendancy_List();
                gpl.setDept_code("1111");
                gpl.setUsr("1111");
                gpl.setPasswd("1111@1111");
                gpl.setDate("01/01/2012");

                Get_All_Pendancy_ListResponse response = serviceStub.get_All_Pendancy_List(gpl);
                System.out.println(response.getGet_All_Pendancy_ListResult());



            } catch(AxisFault e1 ) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }



        }

    }

有什么建议吗?我应该如何设置我的代理配置?

最佳答案

好的..就是这样,这就是您如何通过 axis2 的代码设置代理设置

// Proxy Settings    
HttpTransportProperties.ProxyProperties HTTPProxyProperties = new HttpTransportProperties.ProxyProperties();
HTTPProxyProperties.setProxyName("PROXYHOST");
HTTPProxyProperties.setProxyPort(PROXYPORT);
HTTPProxyProperties.setUserName("USERNAME");
HTTPProxyProperties.setPassWord("PASSWORD");
HTTPProxyProperties.setDomain("DOMAIN");

Options options = serviceStub._getServiceClient().getOptions();
options.setProperty(MessageContextConstants.HTTP_PROTOCOL_VERSION,
HTTPConstants.HEADER_PROTOCOL_10);
options.setProperty(HTTPConstants.PROXY, HTTPProxyProperties);

关于java - org.apache.axis2.AxisFault :Transport error: 407 Error:Proxy Authentication Required,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15476584/

相关文章:

java - Apache FOP - 如何找到哪些数据将打印在哪个页面上

spring - 无法解析对象,因为未在响应中未指定受支持的Content-Type。内容类型为 'text/html;charset=utf-8'

java - Eclipse - 无法在本地主机上发布 Tomcat8.0 服务器的服务器配置

php - 登录名,用户身份验证, session 和csrf token

java - Rust stdout无法在Java应用程序中打印

java - 读取文本文件并存储在 HashMap 中。然后按顺序排序

java - 使用应用程序发送多个 shell 命令

.net - 具有 Rest API 的 .NET 平台架构

java - 检查由类组成的每个实例的用户名和密码

authentication - CakePHP 2 Auth 不工作 - Blowfish