我的Web服务客户端应用程序使用Apache CXF生成客户端存根以与多个Web服务进行通信.生成的CXF Web服务存根对象具有相当大的内存占用(10 - 15个Web服务对象占用超过64 MB的内存).有没有办法减少CXF对象的占用空间?
我有一个从wsdl生成的服务客户端.我正在尝试呼叫远程服务,我收到下面看到的导管启动器错误.我尝试了许多解决方案但没有成功.
我找到了推荐使用http-jetty扩展的解决方案(旧帖子).我不相信这对我有意义,因为服务器没有在本地运行.
我还发现帮助我的最近配置是一个示例cxf.xml文件,其中包含:
<bean class="org.apache.cxf.transport.local.LocalTransportFactory"
lazy-init="false">
<property name="transportIds">
<list>
<value>http://cxf.apache.org/transports/local</value>
<value>http://cxf.apache.org/transports/http</value>
<value>http://schemas.xmlsoap.org/soap/http</value>
<value>http://schemas.xmlsoap.org/wsdl/soap/http</value>
</list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
此配置提供有关如何配置传输工厂并将其绑定到http://schemas.xmlsoap.org/soap/http的指导.当我尝试使用HTTPTransportFactory时,我收到一个异常,它无法初始化(没有这样的方法错误).
Caused by: org.apache.cxf.BusException: No conduit initiator was found for the namespace http://schemas.xmlsoap.org/soap/http.
at org.apache.cxf.transport.ConduitInitiatorManagerImpl.getConduitInitiator(ConduitInitiatorManagerImpl.java:112)
at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:73)
at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:61)
at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:708)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:476)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:309)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:261)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:127)
Run Code Online (Sandbox Code Playgroud)
预防措施:此时,我将停止尝试将我的CXF客户端升级到2.4.2并回退到最老的版本(2.2系列).这不太理想.
我想继续升级.有关如何配置CXF 2.4.X的任何建议,以便我的客户端HTTP SOAP配置正确连接将非常适合.
我有一个CXF WS项目,我会在另一个项目中使用它,我会在Web项目中使用这个WS,但我不知道如何生成Jar文件.
请你有任何想法或一个例子吗?
谢谢
尝试从中调用服务时,我收到以下异常SOAPUI
.当我在浏览器中打开端点时,它显示wsdl正常.
WARN org.apache.cxf.phase.PhaseInterceptorChain - Interceptor for {http://contract.premsisc.usst.com/}PaidClaimFacadeService has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Message part {http://contract.premsisc.uss`enter code here`t.com/}findPaidClaims was not recognized. (Does it exist in service WSDL?)
at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:194)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:113)
at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:97)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:461)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:188)
at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:148)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1655)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1595)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:104)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:908)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:932)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:864)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
at …
Run Code Online (Sandbox Code Playgroud) 我已经使用ApacheCXF(v3.0.4)实现了一个JAX-WS客户端,一切都运行成功,但问题出现在我想使用java 8(jdk1.8.0_25)的安全连接(SSL/TLS)时.
我在log中看到以下异常(-Djavax.net.debug = all):
main, handling exception: java.net.SocketException: Connection reset
main, SEND TLSv1.2 ALERT: fatal, description = unexpected_message
main, WRITE: TLSv1.2 Alert, length = 2
main, Exception sending alert: java.net.SocketException: Connection reset by peer: socket write error
Run Code Online (Sandbox Code Playgroud)
在一个依赖者分析后,我发现问题是由于Java 8没有发送server_name(SNI)但是使用Java 7发送它并且Web服务调用成功.
Java8日志(-Djavax.net.debug = all):缺少"Extension server_name"
[...]
Compression Methods: { 0 }
Extension elliptic_curves, curve names: {secp256r1, sect163k1, sect163r2, secp192r1, secp224r1, sect233k1, sect233r1, sect283k1, sect283r1, secp384r1, sect409k1, sect409r1, secp521r1, sect571k1, sect571r1, secp160k1, secp160r1, secp160r2, sect163r1, secp192k1, sect193r1, sect193r2, secp224k1, sect239k1, …
Run Code Online (Sandbox Code Playgroud) 我使用Apache CXF将大约10个java类作为Web服务公开.
我使用CXF,Axis和.NET生成了客户端.
在Axis和CXF中,生成"服务"或"定位器".通过这项服务,您可以获得"港口"."端口"用于对Web服务公开的方法进行单独调用.
在.NET中,"服务"直接公开对Web服务的调用.
有人可以解释端口,服务,定位器和端点在Web服务方面的区别吗?
轴:
PatientServiceImplServiceLocator locator =
new PatientServiceImplServiceLocator();
PatientService service = locator.getPatientServiceImplPort();
Run Code Online (Sandbox Code Playgroud)
CXF:
PatientServiceImplService locator = new PatientServiceImplService();
PatientService service = locator.getPatientServiceImplPort();
Run Code Online (Sandbox Code Playgroud)
.净:
PatientServiceImplService service = new PatientServiceImplService();
Run Code Online (Sandbox Code Playgroud) 用生成的Java源代码,比如
所有生成的类都是"值对象"类型,没有业务逻辑.如果我向生成的源代码添加方法,如果我重复生成源代码,我将松开这些方法.
这些Java代码生成工具是否提供了"扩展"生成代码的方法?
例如,
我正在使用Spring,CXF和Hibernate构建一个WebService,它在我具有只读访问权限的外部数据库上执行搜索查询.
问题是数据库中的某些条目在文本字段中有奇怪的字符(0x2),并且它似乎用于处理/序列化从Hibernate会话返回的对象的CXF或库(Aegis?)无法处理它:
org.apache.cxf.aegis.DatabindingException: Error writing document.. Nested exception is com.ctc.wstx.exc.WstxIOException: Invalid white space character (0x2) in text to output (in xml 1.1, could output as a character entity)
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?理想情况下,我可以删除这些字符,因为它们对我的输出无关紧要...谢谢!
CXF JAXRS通过处理If-Match,If-Modified-Since和ETags标头提供对许多高级HTTP功能的支持.JAXRS请求上下文对象可用于检查前提条件.还支持Vary,CacheControl,Cookies和Set-Cookies.
我真的很想使用(或至少探索)这些功能.然而,虽然"提供支持"的声音非常有趣,但它在实现这些功能方面并不是特别有用.有关如何使用If-Modified-Since,CacheControl或ETags的任何帮助或指示?
尝试使用Tomcat 7 Maven插件和CXF 2.7.8部署JAX-WS端点.作为优先选择,我不想为Spring或CXF提供任何XML配置.我看到几个博客,文章,帖子使用cxf-servlet.xml
和CXFServlet,但没有任何完全使用Java配置.查看CXFServlet源代码,它会cxf-servlet.xml
在密钥下查找servlet上下文中的任何内容'config-location'
.我尝试以编程方式注册端点而不是in cxf-servlet.xml
,但它不起作用; 我在访问该服务时获得了404.有任何想法吗?
@Configuration
@ImportResource({ "classpath:META-INF/cxf/cxf.xml" })
public class CXFConfig {
@Autowired
Bus cxfBus;
// More code
@Bean
public Endpoint calculator() {
EndpointImpl endpoint = new EndpointImpl(cxfBus, new Calculator());
endpoint.setAddress("/CalculatorService");
return endpoint;
}
}
Run Code Online (Sandbox Code Playgroud)