2013-03-18 105 views
0

這是我的代碼..我嘗試使用.asmx?WSDL webservice。org.apache.axis2.AxisFault:傳輸錯誤:407錯誤:需要代理驗證

錯誤: 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", "[email protected]"); 


       ServiceStub serviceStub = new ServiceStub(); 
       Get_All_Pendancy_List gpl = new Get_All_Pendancy_List(); 
       gpl.setDept_code("1111"); 
       gpl.setUsr("1111"); 
       gpl.setPasswd("[email protected]"); 
       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(); 
      } 



     } 

    } 

什麼建議?我應該如何設置我的代理配置?

+0

是後面代理服務器?。然後,你需要提供代理主機參數後端srvice axis2.xml運輸發件人 – Ratha 2013-03-18 19:19:50

+0

我嘗試設置在axis2.xml的代理服務器設置..但不能讓它工作.. <參數名稱= 「代理」> <配置> example.org 示例\ saminda ppp SaK 2013-03-19 09:31:13

回答

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);