We had the same problem when calling a web service from a servlet deployed to Weblogic using weblogic.jws.jaxws.ClientPolicyFeature and weblogic.wsee.security.unt.ClientUNTCredentialProvider to set the policy, for example:
import weblogic.jws.jaxws.ClientPolicyFeature; import weblogic.jws.jaxws.policy.InputStreamPolicySource; import weblogic.wsee.security.unt.ClientUNTCredentialProvider; ClientPolicyFeature cpf = new ClientPolicyFeature(); InputStream inputStream = ChangeLogBean.class.getClassLoader().getResourceAsStream("usernametoken.xml"); cpf.setEffectivePolicy(new InputStreamPolicySource(new InputStream[]{inputStream})); MyServiceWSPortImplService service = new MyServiceWSPortImplService(new URL(myEndpoint.getUrl()), new QName("http://myhost/myservice/V1", "MyServiceWSPortImplService")); MyService port = service.getMyServicePort(new WebServiceFeature[]{cpf}); ArrayList credentialProviders = new ArrayList(); ClientUNTCredentialProvider untCredentialProvider = new ClientUNTCredentialProvider(myEndpoint.getUser().getBytes(), myEndpoint.getPassword().getBytes()); credentialProviders.add(untCredentialProvider); Map context = ((BindingProvider)port).getRequestContext(); context.put(WSSecurityContext.CREDENTIAL_PROVIDER_LIST, credentialProviders);
But the WebServices stack used by our application is actually Apache CXF, which has a different way of specifying policies (using org.apache.neethi.Policy), as stated here:
http://cxf.apache.org/docs/how-to-define-policies.html#HowtoDefinePolicies-Dynamicallyviamessageproperty
So, the CXF stack basically ignored WSSecurityContext.CREDENTIAL_PROVIDER_LIST, and we got an error: Error checking message against security policy Error code: 1000
In this case, the correct solution would be to use the steps described in the CXF documentation:
- Get the policy from an external location and build it for the current message.
- Parse WS-Policy XML using the Neethi library.
- Save the result of the Policy object to the policy content property Constants.POLICY_OVERRIDE.
I just mention it here if someone else makes the mistake of mixing CXF with Weblogic. :)
source share