LutraLutra LutraLutra - 2 years ago 412
Java Question

Apache CXF - None of the policy alternatives can be satisfied

I'm trying to create client of 3rd party WS. My app is running on JBoss AS 6 (with its Apache CXF 2.3.1 stack). I generated client code by wsconsume (wsdl2java). When I tried to connect to WS a got exception:

No assertion builder for type}BasicAuthentication registered.
Exception in thread "main" None of the policy alternatives can be satisfied.

Auth part of WSDL looks like:

<wsp:Policy wsu:Id="abc_ssl_policy">
xmlns:http="" />
<sp:HttpsToken RequireClientCertificate="false" />
<sp:Basic256 />
<sp:Strict />

Client code:

@WebServiceClient(name = "Abc",
wsdlLocation = "",
targetNamespace = "")
public class Abc extends Service {

public final static URL WSDL_LOCATION;

public final static QName SERVICE = new QName("", "Abc");
public final static QName AbcSsl = new QName("", "abc_ssl");
static {

Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("user", "pas".toCharArray());


URL url = null;
try {
url = new URL("");

} catch (MalformedURLException e) {
"Can not initialize the default wsdl from {0}", "...");

Exception is thrown whe I try get Conduit:

Client client = ClientProxy.getClient(port);
HTTPConduit con = (HTTPConduit) client.getConduit(); <- exception

I suspect that is because of non-standard MS policy and I need proper Intercerptor to handle this policy, but can somebody show me a way how to do it?

I dont even no, where I should put my HTTPS credentials to auth (I can't get conduit)

Answer Source

The problem gone when I used this code:

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.transport.http.HTTPConduit;


JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

//factory.getInInterceptors().add(new LoggingInInterceptor());
//factory.getOutInterceptors().add(new LoggingOutInterceptor());

factory.setAddress(""); <- must be /soap there, otherwise 404

IAbc info = (IAbc) factory.create();

Client client = ClientProxy.getClient(info);
HTTPConduit http = (HTTPConduit) client.getConduit();


String abc =;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download