CXF如何在没有Spring的CXF端口上设置SoapVersion [英] CXF How to set SoapVersion on CXF port without Spring

查看:413
本文介绍了CXF如何在没有Spring的CXF端口上设置SoapVersion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用CXF没有Spring配置文件的Web服务客户端。



它工作相当不错,但我不知道如何设置绑定SoapVersion Java Api。
使用Spring文件,如下所示:

 < jaxws:binding> 
< soap:soapBinding version =1.2/>
< / jaxws:binding>

你们知道如何在Java代码中做这件事(在Port上,在SOAPBinding。 ..)?



感谢您的帮助!



--------------



我仍然坚持这个问题...
我试图添加SOAPBinding注释在接口上建议的响应之一,但它不工作...
我仍​​然在寻找一种方式手动配置我的PortType /绑定/总线使用Soap 1.2 ...



有任何想法吗?



EDIT ----------------- -----



问题解决!实际上我回答了自己的问题:



谢谢!

解决方案>

Ok我再次回答我自己的问题,以分享解决方案。
在CXF邮件列表中的人的帮助下,我找到了一个适用于我的解决方案。
实际上有两种方法来解决这个问题。
以下是解释:



问题来自我建立CXF服务的方式。



第一个解决方案是在服务创建时指定WSDL位置:

  //创建服务
服务service = Service.create(urlToWsdl,serviceQName);
//访问端口
return service.getPort(serviceQName,portTypeClass);

这解决了问题,但我不想有到WSDL的链接,因此这里是第二个解决方案摆脱这个链接:

  //创建服务
服务service = Service.create serviceQName);
//为服务添加一个端口并指定SOAP 1.2绑定
service.addPort(serviceQName,javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING,wsUrl);
//访问端口
return service.getPort(serviceQName,portTypeClass);

在我的项目中,我们决定选择第二种解决方案。



希望这有助于!


I am currently working on a Web Service client using CXF without Spring configuration files.

It works pretty well but I cannot figure out how to set the binding SoapVersion using the Java Api. Using a Spring file this is done as the following:

<jaxws:binding>
    <soap:soapBinding version="1.2"/>
</jaxws:binding>

Do you guys know how to do this in the Java code (on the Port, on the SOAPBinding...)?

Thanks in advance for your help!

EDIT----------------------

I'm still stuck with this problem... I tried to add the SOAPBinding annotation on the interface as suggested in one of the response below but it didn't work... I'm still searching for a way to manually configure my PortType / Binding / Bus to use Soap 1.2...

Any ideas?

EDIT----------------------

Problem solved! Actually I answered my own question: see below...

Thanks!

解决方案

Ok I answer again to my own question to share the solution. With the help of the guys from the CXF mailing list I found a solution that works for me. There is actually 2 ways to solve the problem. Here is the explanation:

The problem came from the way I was building my CXF Service.

The first solution is to specify the WSDL location at Service creation time:

// Create the service
Service service = Service.create(urlToWsdl, serviceQName);
// Access the port
return service.getPort(serviceQName, portTypeClass);

This solved the problem but I didn't want to have that link to the WSDL, so here is the second solution that gets rid of this link:

// Create the service
Service service = Service.create(serviceQName);
// Add a Port to the service and specify the SOAP 1.2 binding
service.addPort(serviceQName, javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING, wsUrl);
// Access the port
return service.getPort(serviceQName, portTypeClass);

In my project we decided to choose the second solution.

Hope this helps!

这篇关于CXF如何在没有Spring的CXF端口上设置SoapVersion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆