繁体   English   中英

cxf ws客户端向服务器发送请求的最佳实践(肥皂)

[英]best practice for cxf ws client to send request to server (soap)

我有一个春季的webapp。 需要一个屏幕来调用另一个Web服务(Soap协议-不很忙)。 我正在使用cxf以合同优先的方式开发该Web服务客户端。 基本上,我遵循cxf示例代码:

customerServiceService = new CustomerServiceService(wsdlURL);
CustomerService customerService = customerServiceService.getCustomerServicePort();
customerService.getCustomersByName("AAAA");

到现在为止还挺好。 但是现在从我的应用程序调用该Web服务的数量约为每天1万。 您知道如何改进代码或向cxf配置中添加一些参数以优化高容量的性能吗? 我无法修改服务器代码。 问题仅适用于我的客户代码。

我能想到的改进之一是,避免为每个请求创建Webservice对象。 只要您没有修改拦截器等,客户端都是线程安全的。 在此处查看更多信息。

我相信您一定不能为每个请求创建Web服务客户端。 如果是,则创建客户端的bean并将其注入spring配置。

可以通过SpringBus配置Cxf,因此配置cxf总线并提供否。 根据您的要求进行连接。

SpringBus bus = new SpringBus();
        bus.setProperty(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
        bus.setProperty("org.apache.cxf.transport.http.async.SO_KEEPALIVE",Boolean.TRUE);
        bus.setProperty("org.apache.cxf.transport.http.async.SO_TIMEOUT",Boolean.FALSE);
        bus.setProperty("org.apache.cxf.transport.http.async.MAX_CONNECTIONS","totalConnections"));
                bus.setProperty("org.apache.cxf.transport.http.async.MAX_PER_HOST_CONNECTIONS","connectionsPerHost"));

默认的总连接数为5000,因此默认值可能就足够了。 我认为此配置应为您带来性能上的好处。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM