[英]best practice for cxf ws client to send request to server (soap)
I have a spring webapp. 我有一个春季的webapp。 There is a screen need to make a call to another webservices (Soap protocol- not restful). 需要一个屏幕来调用另一个Web服务(Soap协议-不很忙)。 I am using cxf to develop that web service client with contract first approach. 我正在使用cxf以合同优先的方式开发该Web服务客户端。 basically, I follow the cxf sample code: 基本上,我遵循cxf示例代码:
customerServiceService = new CustomerServiceService(wsdlURL);
CustomerService customerService = customerServiceService.getCustomerServicePort();
customerService.getCustomersByName("AAAA");
So far so good. 到现在为止还挺好。 But the number of calling that web service from my app now is about 10k/day. 但是现在从我的应用程序调用该Web服务的数量约为每天1万。 Do you know how to improve my code or add some parameters to cxf configuration to optimize the performance for that high volume? 您知道如何改进代码或向cxf配置中添加一些参数以优化高容量的性能吗? I am not able to modify server code. 我无法修改服务器代码。 The question is for my client code only. 问题仅适用于我的客户代码。
I believe you must not be creating webservice client per request. 我相信您一定不能为每个请求创建Web服务客户端。 If yes than create a bean of the client and inject it in spring configuration. 如果是,则创建客户端的bean并将其注入spring配置。
Cxf can be configured through SpringBus so configure cxf bus and provide no. 可以通过SpringBus配置Cxf,因此配置cxf总线并提供否。 of connection as per your requirement. 根据您的要求进行连接。
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"));
Default Total Connection is 5000 so default may be enough. 默认的总连接数为5000,因此默认值可能就足够了。 I think this configuration should give you a performance benefit. 我认为此配置应为您带来性能上的好处。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.