报错:axis2.AxisFault: Transport error: 401 Error: Unauthorized

axis2.AxisFault: Transport error: 401 Error: Unauthorized

报错:axis2.AxisFault: Transport error: 401 Error: Unauthorized

WebService项目WSDL生成代码之后传数据报错,需要添加用户名和密码,
多次调试找到了个可行的方法。
解决方法:
SI_03DU6_ZHTJFXXT2ERP_XMJBXXServiceStub stub = new SI_03DU6_ZHTJFXXT2ERP_XMJBXXServiceStub();
HttpTransportPropertiesImpl.Authenticator auth = new HttpTransportPropertiesImpl.Authenticator();
auth.setUsername(“");//用户名
auth.setPassword("
*”);//密码
stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, auth);
完美解决。
报错:axis2.AxisFault: Transport error: 401 Error: Unauthorized