CXF With UsernameToken (WS-Security Policy)

Testing CXF UsernameToken Example With soapUI

Here we are using soapUI for testing CXF UsernameToken example

New soapUI Project soapUI WSDL Import

Run

On following screen shot, you can see the blue lines, which is specifying username as "joe", password as "joespassword" and WSS-Password Type as "PasswordText"

soapUI With UsernameToken

Run

You can also use wsimport tool for testing this service. Only thing need to change is modify the Main class according to below class

package com.client;

import java.util.Map;

import com.student.ChangeStudentDetails;
import com.student.ChangeStudentDetailsImplService;
import com.student.Student;
import javax.xml.ws.BindingProvider;
//CXF UsernameToken Example
public class Main {
 
public static void main(String[] args) {
   
ChangeStudentDetailsImplService service = new ChangeStudentDetailsImplService();
    ChangeStudentDetails changeStudentDetailsImplPort = service.getChangeStudentDetailsImplPort
();

    Map ctx =
((BindingProvider) changeStudentDetailsImplPort).getRequestContext();
    ctx.put
("ws-security.username", "joe");
    ctx.put
("ws-security.password", "joespassword");

    Student student =
new Student();
    student.setName
("Rockey");
    student = changeStudentDetailsImplPort.changeName
(student);
    System.out.println
(student.getName());

 
}

}
Output
Hello Rockey

 





Previous 1 2 3 4








11 Responses to "CXF With UsernameToken (WS-Security Policy)"
  1. Rone 2012-08-23 08:00:02.0
  1. Reality 2012-08-24 08:00:02.0
  1. admin 2012-08-25 08:00:02.0
  1. nityananda 2012-08-26 08:00:02.0
  1. admin 2012-08-27 08:00:02.0
  1. linuxks 2012-08-27 18:00:02.0
  1. Vishnu.K 2012-08-27 22:00:02.0
  1. admin 2012-08-28 08:00:02.0
  1. Ashley 2012-08-28 18:00:02.0
  1. Ashley 2012-08-28 22:00:02.0
  1. Kerim 2012-08-29 08:00:02.0

Your email address will not be published. Required fields are marked *