Cxf HTTPS Client Example

I need a Cxf client that can handle the HTTPS wsdl url. The cxf documentation is not very large, so I would appreciate help.

Is there any example of what I want? google is not my friend today :(

Thanks for helping me.


EDIT1: I just don't know how to do this. When I try:

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setAddress("https://mysite/view/ext-services/dpDataService?wsdl");
factory.setServiceClass(DPDataService.class);
DPDataService client = (DPDataService) factory.create();
client.getAllHostServiceMetric("1", "1");

I have an error:

 Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Could not find conduit initiator for transport 

edit2:

with:

factory.setWsdlURL

i has an error:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

EDIT3:

I create a keystore and add a certificate, then set the property:

System.setProperty("javax.net.ssl.trustStore", "myKeyStore");
System.setProperty("javax.net.ssl.trustStorePassword", "password");

But now the error: An exception in the stream "main" org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://unknown.namespace/}

I see the console saying: reating Service { http: //unknown.namespace/ }

Maybe I forgot something.


EDIT4: a lot of news:

It seems that https is no longer a problem. but i still need help :)

So here is this code:

JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
        Client client = factory.createClient("https://url/services?wsdl");
Object[] res = client.invoke("getSomething", "param");

I have an error:

Caused by: org.xml.sax.SAXParseException: Both jaxb:version and version are present

Another code:

ClientProxyFactoryBean

=> some error

with: JaxWsProxyFactoryBean + setWsdlURL

Could not find definition for service {http://unknown.namespace/}DPDataServiceService.
+3

Source: https://habr.com/ru/post/1744792/


All Articles