performanceweb-servicescxfwebservice-clientwebservices-client

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


I have a spring webapp. There is a screen need to make a call to another webservices (Soap protocol- not restful). I am using cxf to develop that web service client with contract first approach. basically, I follow the cxf sample code:

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. Do you know how to improve my code or add some parameters to cxf configuration to optimize the performance for that high volume? I am not able to modify server code. The question is for my client code only.


Solution

  • I believe you must not be creating webservice client per request. If yes than create a bean of the client and inject it in spring configuration.

    Cxf can be configured through SpringBus so configure cxf bus and provide no. 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. I think this configuration should give you a performance benefit.