我想编写一个调用Web服务(域中的IIS)的.jsp(tomcat5.5)。我收到HTTP错误401未经授权。似乎为了调用Web服务,您必须是域用户。我想只允许域用户访问jsp。 jsp中的request.getRemoteUser()返回null,但不调用调用jsp的域用户。
从网络浏览器我调用Web服务,它运行正常。
我对此有点困惑。有人能告诉我这个问题怎么解决? 我是否必须让tomcat制作SSO?
感谢您的时间。
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter o = response.getWriter();
o.println("sstarting...");
o.println("user.name ".concat(System.getProperty("user.name")));
o.println("request.getRemoteUser() ".concat(request.getRemoteUser()));
try {
GetUserRoles getUserRolesRequest = new GetUserRoles();
getUserRolesRequest.setApplicationId(121);
getUserRolesRequest.setUserName("user");
GetUserRolesResponse getUserRolesResponse;
ServiceStub stub =new ServiceStub() ;
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED,"false");
getUserRolesResponse = stub.getUserRoles(getUserRolesRequest); //IT FAILS HERE 401
String str =getUserRolesResponse.getGetUserRolesResult().toString();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
o.println(e.getMessage());
}
}