这是我的代码..我正在尝试使用.asmx?WSDL webservice。
错误: 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();
}
}
}
任何建议?我该如何设置代理配置?
答案 0 :(得分:2)
好的..这就是,这是你可以通过代码设置轴2的代理设置
// 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);