Search code examples
javasoapauthorizationtestngjax-ws

SOAP. JAX-WS. Authorization


  1. So, i have parsed WSDL by -wsimport to my project.
  2. Then, i initialize them
  3. Did some request

soapServicePortType = Interface, where is methods of WSDL. getHouseCall = GETmethod of info

screen

  1. But i should authorizate

  2. As i see in stacktrace, message building by HttpTransportPipe class. In this class i found method "addBasicAuth", when i can insert Login and pass.

So, i have 2 questions:

  1. How to make my request use "addBasicAuth" method when it building request
  2. How to add one header (coockie) to it?

Solution

  • I solved it so:

    ((BindingProvider) /*Insert InterfaceClass of port WSDL*/).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "login");
    ((BindingProvider) /*Insert InterfaceClass of port WSDL*/).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "password");
    

    And no need to sending coockies