Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @WebMethod(operationName = "autentica")
- public String autentica() {
- MessageContext mContext = wsContext.getMessageContext();
- Map http_headers = (Map) mContext.get(MessageContext.HTTP_REQUEST_HEADERS);
- List userList = (List) http_headers.get("Username");
- List passList = (List) http_headers.get("Password");
- String username = "";
- String password = "";
- if(userList != null) {
- username = userList.get(0).toString();
- System.out.println("User: " + userList.get(0).toString());
- }
- if(passList != null) {
- password = passList.get(0).toString();
- System.out.println("Pass: " + passList.get(0).toString());
- }
- if (username.equals("admin") && password.equals("admin")){
- return "Hello World JAX-WS - Valid User!";
- }else{
- return "Unknown User!";
- }
- }
- $soap.setCredentials("admin","admin");
- $soap.post(url, "autentica").then(
- function(response) {
- console.log(response);
- }
- );
- <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
- <S:Body>
- <ns2:autenticaResponse xmlns:ns2="http://service.natal.rn.gov.br/">
- <return>Unknown User!</return>
- </ns2:autenticaResponse>
- </S:Body>
- </S:Envelope>
- $soap.setCredentials("username","password");
- xmlHttp.setRequestHeader("Authorization", "Basic " + SOAPClient._toBase64(SOAPClient.userName + ":" + SOAPClient.password));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement