I have a wsdl that defines a soap header that needs to be passed when calling the web service.
The sample SOAP Header is:
&
Found myself in same situation: wsdl2java generated the header class, and I needed to add it as a SOAP header to the outgoing SOAP request.
My solution in code was as follows (reusing original question's AuthenticationInfo as the header class name):
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.headers.Header;
AuthenticationInfo ai = new AuthenticationInfo();
ai.setUserName("User");
ai.setPassword("");
List soapHeaders = new ArrayList();
Header h1 = new Header(new QName("http://namespace/of/AuthenticationInfo", "AuthenticationInfo"),
ai, new JAXBDataBinding(AuthenticationInfo.class));
soapHeaders.add(h1);
ClientProxy.getClient(port).getRequestContext().put(Header.HEADER_LIST, soapHeaders);