Client CXF + WS-security + SSL
Salutation,
je fais appel à votre aide pour résoudre mon problème.
Mon objectif est le développement d'un client pour un service SOAP.
Je dispose de :
Citation:
Endpoint address,
WSDL,
Target namespace
J'ai également le user/password.
Tout fonctionne pour le mieux dans SoapUI.
Maintenant concernant le client java :
Le SSL ne semble plus me poser de problème depuis l'ajout du certificat (keystore).
Le problème semble s'orienter vers ws-security.
J'ai essayé divers code, renvoyant des erreurs différentes :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
Map outProps = new HashMap();
outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
outProps.put(WSHandlerConstants.USER, USER);
outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordCallback.class.getName());
factory.setJaxbContextProperties(outProps);
Client client = factory.createClient(WSDL);
client.invoke("getX", "param"); |
l'erreur renvoyée :
Code:
1 2
|
Caused by: org.xml.sax.SAXParseException: Both jaxb:version and version are present |
autre code tenté :
Code:
1 2 3 4 5 6 7 8
|
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setServiceClass(MyObj.class);
factory.setAddress(ENDPOINT);
factory.setUsername(USER);
factory.setPassword(PWD);
MyObj client = (MyObj) factory.create();
client.getX("param"); |
L'erreur renvoyée :
Code:
1 2
|
org.apache.cxf.binding.soap.SoapFault: An error was discovered processing the <wsse:Security> header |
Une autre expérience :
Code:
1 2 3 4 5 6 7 8
|
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(MyObj.class);
factory.setUsername(USER);
factory.setPassword(PWD);
factory.setAddress(ENDPOINT);
MyObj client = (MyObj) factory.create();
client.getX("param"); |
erreur :
Code:
1 2
|
javax.xml.ws.soap.SOAPFaultException: An error was discovered processing the <wsse:Security> header |
Une autre ...
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
Service service = Service.create(SERVICE_NAME);
service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, ENDPOINT);
MyObj hw = service.getPort(MyObj.class);
Client client = ClientProxy.getClient(hw);
Endpoint cxfEndpoint = client.getEndpoint();
Map<String,Object> outProps= new HashMap<String,Object>();
outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
outProps.put(WSHandlerConstants.USER, USER);
outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordCallback.class.getName());
WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
cxfEndpoint.getOutInterceptors().add(wssOut);
System.out.println(hw.getX("param")); |
erreur renvoyé :
Code:
1 2
|
Caused by: java.net.MalformedURLException: Invalid address. Endpoint address cannot be null. |
notez qu'en fait ENDPOINT n'est pas nul... :aie:
Voila, j'ai fait le tour des solutions et pas de résultat potable. Le plus triste étant que cela fonctionne sans problème sous SoapUI...
J'accepterais volontiers l'aide d'une âme charitable ;)