Estoy intentando crear un cliente de WS de terceros. Mi aplicación se ejecuta en JBoss AS 6 (con su pila Apache CXF 2.3.1). Genere el código del cliente por wsconsume (wsdl2java). Cuando intenté conectar con WS una excepción conseguido:Apache CXF - Ninguna de las alternativas de política se puede satisfacer
No assertion builder for type http://schemas.microsoft.com/ws/06/2004/policy/http}BasicAuthentication registered.
Exception in thread "main" org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied.
de autenticación parte de WSDL se parece a:
<wsp:Policy wsu:Id="abc_ssl_policy">
<wsp:ExactlyOne>
<wsp:All>
<http:BasicAuthentication
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>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
El código de cliente:
@WebServiceClient(name = "Abc",
wsdlLocation = "https://hiddendomain.com/abc/abc.svc?wsdl",
targetNamespace = "http://tempuri.org/")
public class Abc extends Service {
public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("http://tempuri.org/", "Abc");
public final static QName AbcSsl = new QName("http://tempuri.org/", "abc_ssl");
static {
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("user", "pas".toCharArray());
}
});
URL url = null;
try {
url = new URL("https://hiddendomain.com/abc/abc.svc?wsdl");
} catch (MalformedURLException e) {
java.util.logging.Logger.getLogger(DistrInfo.class.getName())
.log(java.util.logging.Level.INFO,
"Can not initialize the default wsdl from {0}", "...");
}
WSDL_LOCATION = url;
}
excepción se produce cuando planees Intento conseguir Conduit :
Client client = ClientProxy.getClient(port);
HTTPConduit con = (HTTPConduit) client.getConduit(); <- exception
I s Tenga en cuenta que esto se debe a una política de EM no estándar y necesito un Interceptor adecuado para manejar esta política, pero ¿alguien puede mostrarme una forma de hacerlo?
yo incluso no, donde debo poner mis credenciales HTTPS auth (no puedo conseguir conducto)
Gracias, que resolvieron mi problema también. Al principio estaba usando un servicio HTTP, pero después de cambiar a HTTPS obtuve la temida excepción PolicyException. Inicialmente hice 'MyService ss = new MyService (nueva URL (wsdlUrl), nueva QName (" http://tempuri.org/ "," MyService ")); IMyService port = ss.getBasicHttpBindingIMyService(); '. Ahora hago 'JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass (IMyService.class); factory.setAddress (wsdlUrl.replace ("? wsdl", "")); IMyService port = (IMyService) factory.create(); '. – neu242
¡Esto fue realmente útil! ¡¡Gracias!! –
Tengo el mismo problema ... mientras el código estaba funcionando en Tomcat, pero cuando implemente el código en jboss recibo este error. puede por favor compartir el código completo del programa del cliente. – aravind