问题
I am trying to write Java client for .NET web service using CXF but when calling "client.getConduit()", it throws Exception - org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied. Please help!
Here is the code snippet-
ServiceClass service = new ServiceClass();
PortClass port = service.getPort(ServiceClass.class);
Client client = ClientProxy.getClient(port);
HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
final HTTPClientPolicy httpClientPolicy = httpConduit.getClient();
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setAutoRedirect(true);
final BindingProvider bindingProvider = (BindingProvider) port;
final Map<String, Object> requestContext = bindingProvider.getRequestContext();
final Credentials credentials = new NTCredentials(USERNAME, PASSWORD, "", DOMAIN);
requestContext.put(Credentials.class.getName(), credentials);
requestContext.put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
Here is the ws policy snippet from wsdl -
<wsp:Policy wsu:Id="httpsendpoint_policy">
<wsp:ExactlyOne>
<wsp:All>
<http:NegotiateAuthentication xmlns:http="http://schemas.microsoft.com/ws/06/2004/policy/http" />
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken RequireClientCertificate="false" />
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256 />
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict />
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
<wsaw:UsingAddressing />
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
来源:https://stackoverflow.com/questions/36630212/cxf-throws-none-of-the-policy-alternatives-can-be-satisfied