0

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

错误: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();
            }



        }

    }

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

4

1 回答 1

2

好的..就是这样,这就是您可以通过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);
于 2013-03-20T06:50:18.393 回答