I need to incorporate an authentication header (i.e. as a part of SOAP header request) in my new web service. That authentication header will verify the userId and password details. I have to verify the content of request header details for authentication in my Web Service. If authenticated, then the SOAP body of the request will be processed, else Invalid Authentication message will be send back by the Web Service to the client application invoking the service.
I am not able to understand how to create a web service where the SOAP Header will contain some elements(in my case, authentication elements such as userId and password).
Normally, whatever method exposed in the service will come as a part of the SOAP Body. Hence confused how to proceed with adding authentication elements in the SOAP Header.
Please help
Regards,
Recently I have wrote a class which adds user credentials to
SOAP
header. To do that you need to create a class which implementsSOAPHandler<SOAPMessageContext>
interface. For e.g.:Note that I am just adding the credentials to the header and returning
true
. You do what ever you want with whole message and returnfalse
if something that is expected fails.I have implemented this one the client:
But it also can be implemented on the
endpoint
.We can get header from the envelop only not from soap message.