Is there a way to nest/add child elements to SoapHeaderElement? I have looked around to no avail. Need to add a security soap header with the standard Security, UsernameToken, Username and Password.
Similar posts I have looked at:
Add child elements to custom SOAP header in Spring-WS
How to add child element in soap header in java
What I need to add to the SOAP envelope:
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="">
<wsse:Username></wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"></wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
I have tried casting to SOAPHeaderElement instead, since that actually has an addChild method, but get a casting error:
java.lang.ClassCastException: org.springframework.ws.soap.axiom.AxiomSoapHeaderElement cannot be cast to javax.xml.soap.SOAPHeaderElement
Any fix to this casting error or workaround otherwise?