天天看點

設定axis2通路webservice 權限

在ServiceStub class 中加入以下代碼

org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized  

serviceClient = new org.apache.axis2.client.ServiceClient(  

              configurationContext, _service);       

       HttpTransportProperties.Authenticator basicauth = new HttpTransportProperties.Authenticator();  

       basicauth.setUsername("xxx");  

       basicauth.setPassword("xxx");   

       _serviceClient.getOptions().setProperty(HTTPConstants.AUTHENTICATE, basicauth);