0
我在標題中提到的問題是明確的用戶名和密碼,任何幫助,將不勝感激......的ejb基本身份驗證JAX-RPC Web服務如何獲得的請求
順便說一句,我的服務在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