Web services 带有基本身份验证的ejbjax-rpcweb服务如何获取请求的用户名和密码

Web services 带有基本身份验证的ejbjax-rpcweb服务如何获取请求的用户名和密码,web-services,security,authentication,jboss,ejb-3.0,Web Services,Security,Authentication,Jboss,Ejb 3.0,问题很清楚,正如我在标题中提到的,任何帮助都将不胜感激 顺便说一下,我的服务运行在JBoss4.2.2GA上,我使用的是MyEclipse7.5 此外,在这里,我曾经尝试过但不适用于我 @Stateless @WebService(name = "BaseService", targetNamespace = "http://base.ws.listingapi.gg.com") @SOAPBinding(style = SOAPBinding.Style.RPC) @WebContext(co

问题很清楚,正如我在标题中提到的,任何帮助都将不胜感激

顺便说一下,我的服务运行在JBoss4.2.2GA上,我使用的是MyEclipse7.5 此外,在这里,我曾经尝试过但不适用于我

@Stateless
@WebService(name = "BaseService", targetNamespace = "http://base.ws.listingapi.gg.com")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@WebContext(contextRoot = "/listingapi/ws")
public abstract class BaseService {
    ..

    MessageContext mctx = webServiceContext.getMessageContext();

    webServiceContext.getUserPrincipal(); //WITH THIS ONE I could get the username but of course not password..
    System.out.println(mctx.get("password"));

    Map http_headers = (Map) mctx.get(MessageContext.HTTP_REQUEST_HEADERS);
    List userList = (List) http_headers.get("Username");
    List passList = (List) http_headers.get("Password");
[已解决] 我找到了解决办法,就在这里

@Context
protected HttpServletRequest request;
@Context
protected HttpServletRequest request;


[解决]我找到了解决方案,就在这里

@Context
protected HttpServletRequest request;
@Context
protected HttpServletRequest request;

@Context
protected WebServiceContext context;
request.getUserPrincipal().getName(); 
//OR
context.getUserPrincipal().getName();
//will return the username used to getting logged in