Search code examples
javasoapsoapuiws-securityws-addressing

How to add ws-security in SoapUI JAX-WS generated code


I create a project in SoapUi from a WSDL where the request must have ws-addressing and ws-security.

The question is where I have to configure SoapUI to add ws-security and ws-addressing so the generator takes that values and include in the Java clasess that creates.

I did it first on the request soap message, but generator didnt use it. Then I added to the Outgoing WS-Security Configurations, but the same result. The clases are the same as if I never set that conf.

What I m missing?


Solution

  • [EDIT]

    wsimport must have generated a service port class that's name suffix is "_Service".

    YourServiceName_Service svcPort;
    
    // ....
    
    Map<String, Object> request = ((BindingProvider) svcPort).getRequestContext();
    request.put(BindingProvider.USERNAME_PROPERTY, "<username>");
    request.put(BindingProvider.PASSWORD_PROPERTY, "<password>");
    

    You must set ws-security credentials on base classes of autogenerated classes. This example may help you

    http://java.globinch.com/enterprise-java/web-services/jax-ws/secure-usernametoken-java-web-services-using-metro-wsit/#jax-ws-usernametoken-client-example