问题很明显,正如我在标题中所提到的,任何帮助都会受到赞赏......
顺便说一句,我的服务是在Jboss 4.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 WebServiceContext context;
...
request.getUserPrincipal().getName();
//OR
context.getUserPrincipal().getName();
//will return the username used to getting logged in
答案 0 :(得分:0)
[求助]我找到了解决方案,就在这里;
@Context
protected HttpServletRequest request;
或者
@Context
protected WebServiceContext context;
...
request.getUserPrincipal().getName();
//OR
context.getUserPrincipal().getName();
//will return the username used to getting logged in