Is this correct method of setting SOAP Header.
The general look may be about that. But in a closer look, it is very approximative and not really correct.
I am trying add a SOAP header in a WebServiceMessageCallback object , [...]
Not sure what is your calling WebServiceMessageCallback object, may be something essentially the same as SOAPMessageContext, and that's what I would take...
Disregard all the uncertainties associated with header, of its come about etc, the use the QName there is already incorrect. You set up the QName with a namespace-uri (your "url") as the first argument, the second argument "headerName" would be its local name. If you want to use the constructor with three arguments, the third would be related to the prefix you want to have. It is not "value of header" from what it means to suggest being the "value" (text content) of the SOAPHeaderElement. No.
Here is how it would appear to achieve in that direction.
I am setting the "endpoint" as the "url"
The endpoint's url is actually not necessarily the namespace-uri appeared as the first argument of the QName() setup. "Not necessarily" is conceptually meaning "not at all". Be careful. You have to determine the namespace-uri independently of the endpoint's url: from the wsdl or the
java code in the code-first approach.