我正在研究集成测试用例,作为不同测试用例的一部分,我为请求设置了http超时意味着我想向服务器发出http请求,但是在收到请求之前,应该从客户端发生超时。由于我使用的是CXF,我根据官方网站提供的解决方案进行了更改, How to configure the HTTPConduit for the SOAP Client?
我已经存在一个问题, changing client timeout for a particular request in Apache CXF
我的问题, 我有从cxf codegen插件生成的java类,其中生成了一个具有所有soap web服务操作的接口。
URL wsdl = getClass().getResource("wsdl/CustomerService_1.wsdl");
QName serviceName = new QName("srv.retail.app:ws:customer:1", "CustomerService_1");
QName portName =
new QName("srv.retail.app:ws:customer:1", "CustomerService_1PortTypeSoap11");
CustomerService_1 service = new CustomerService_1(wsdl, serviceName);
CustomerService1PortType customerServicePortType = service.getPort(portName, CustomerService1PortType.class);
Client client = ClientProxy.getClient(customerServicePortType);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(36000);
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setReceiveTimeout(300);
http.setClient(httpClientPolicy);
尝试了不同的方法,如果你对此提出意见,那将会很棒。