I'm working on a spring boot app with soap client trying to connect to soap web service secured using header so that I try to use an interceptor based on Wss4jSecurityInterceptor this my client configuration
when I called the Soap WS I get this error :
org.springframework.ws.soap.client.SoapFaultClientException: An error was discovered processing the <wsse:Security> header
at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:38) ~[spring-ws-core-2.4.0.RELEASE.jar:2.4.0.RELEASE]
at org.springframework.ws.client.core.WebServiceTemplate.handleFault(WebServiceTemplate.java:830) ~[spring-ws-core-2.4.0.RELEASE.jar:2.4.0.RELEASE]
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:624) ~[spring-ws-core-2.4.0.RELEASE.jar:2.4.0.RELEASE]
In my config class :
@Bean
public Wss4jSecurityInterceptor securityInterceptor() {
Wss4jSecurityInterceptor security = new Wss4jSecurityInterceptor();
// what should I add here
return security;
}
@Bean
public SOAPConnector soapConnector(Jaxb2Marshaller marshaller)throws Exception {
SOAPConnector client = new SOAPConnector();
client.setDefaultUri(defaultUri);
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
client.setInterceptors(new ClientInterceptor[]{ securityInterceptor() });
client.setMessageSender(httpComponentsMessageSender());
return client;
}
And this my client :
@Component
public class SOAPConnector extends WebServiceGatewaySupport {
public Object callWebService(String url, Object request){
return getWebServiceTemplate().marshalSendAndReceive(url, request);
}
}
This's the security header that I want to add to my client :
<wsse:Security 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:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="X509-FD1EC894572B22912315605098864444600">MIIC1zCCAkACAiWNMA0GCSqGSIb.....=
</wsse:BinarySecurityToken>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="SIG-3068">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="soap"/>
</ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#id-3067">
<ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList=""/>
</ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>C7JMsbXSGGOrlvGi+fIeoViI3aI=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>KDNG2Og3FcDNMvgyii/U....==</ds:SignatureValue>
<ds:KeyInfo Id="KI-FD1EC894572B22912315605098864444601">
<wsse:SecurityTokenReference wsu:Id="STR-FD1EC894572B22912315605098864444602">
<wsse:Reference URI="#X509-FD1EC894572B22912315605098864444600" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
</wsse:Security>