Skip to main content

How to fix org.apache.cxf.ws.policy.PolicyException: These policy alternatives can not be satisfied

How to fix – org.apache.cxf.ws.policy.PolicyException: These policy alternatives can not be satisfied:

I encountered this error when trying to call a secure web service which had username password authentication along with Timestamp authentication.

Exception

I got following exception when I was calling secure web service

 

Following steps helped me fix this problem, hope it helps.

  • Getting an instance of PolicyInterceptorProviderRegistry from CXF Bus
  • Adding the QNames to IgnorablePolicyInterceptorProvider
  • Registering the IgnorablePolicyInterceptorProvider to PolicyInterceptorProviderRegistry

Dependency Check

Make sure that you have relevant POM dependencies

Code Changes

  • Get instance of CXF Bus
  • From the CXF Bus get the PolicyInterceptorProviderRegistry
  • Create a set of QName and add all the failing policy alternatives to IgnorablePolicyInterceptorProvider, in my case it was IncludeTimestamp and TransportBinding so I am adding those 2 only
  • Register them with PolicyInterceptorProviderRegistry

 

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Bitnami