Cxf HTTPS 客户端示例

发布于 2024-09-01 03:38:27 字数 2137 浏览 7 评论 0原文

我需要一个可以处理 HTTPS wsdl url 的 Cxf 客户端。 cxf 文档并不是很大,所以我希望得到一些帮助。

有我想要的例子吗?谷歌今天不是我的朋友:(

谢谢你帮助我。


编辑1: 我只是不知道该怎么做。 当我尝试:

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");

我有错误:

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

EDIt2:

使用:

factory.setWsdlURL

我有错误:

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:

我创建一个密钥库并添加证书,然后我设置属性:

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

但现在错误是线程“main”中出现异常 org.apache.cxf.service.factory.ServiceConstructionException: 无法找到服务 {http://unknown.namespace/} 的定义

我看到控制台显示:reating Service {http://unknown.namespace/}

也许我忘记了什么。


EDIT4:许多新闻:

似乎 https 不再是问题。 但我仍然需要帮助:)

所以这里的代码:

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

我有错误:

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

另一个代码:

ClientProxyFactoryBean

=>一些错误

JaxWsProxyFactoryBean + setWsdlURL

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

I need a Cxf client which can deal with HTTPS wsdl url.
The cxf documentation isn't really big, so i would appreciate some help.

Is there any example of what i want ? google isn't my friend today :(

Thx 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 the error :

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

EDIt2:

with :

factory.setWsdlURL

i have the 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 the certificate, then i set the property:

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

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

i see that the console say : reating Service {http://unknown.namespace/}

maybe i forgot something.


EDIT4 : Many news :

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

So here with this code :

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

I have the 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文