解决 webservice 调用之后报错:调用异常:Transport error : 401 Error:Unauthorized 授权失败。
加入如下代码
//Sap需要ws-security的认证,调用sap webservice的认证信息需要输入用户名和密码:
HttpTransportProperties.Authenticator sapAuth = new HttpTransportProperties.Authenticator();
sapAuth.setUsername("hh_niuc");
sapAuth.setPassword("654321"); ServiceStub stubClient = getSyncStub();//这个client是你自己的client,注意修改!
stubClient._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, sapAuth);