---
title: "cxf超时设置"
author: "openstudy"
date: "2011-07-05T14:49:46Z"
tags: []
categories: ["开源软件"]
slug: "cxf"
draft: false
lastmod: "2011-07-05T14:52:19Z"
id: 1114916
url: "https://openstudy.iteye.com/blog/1114916"
---

http://download.oracle.com/docs/cd/E20686_01/English/Technical_Documentation/Web_Services/ProgrammersGuide/helpmain.htm?toc.htm?34314.htm

        //调用WebService
        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setServiceClass(IHelloWorldService.class);
        factory.setAddress("http://localhost:9000/helloWorld");
        IHelloWorldService client = (IHelloWorldService) factory.create();
        
        ///开始超时设置
        Client proxy = ClientProxy.getClient(client);
        HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
        HTTPClientPolicy policy = new HTTPClientPolicy();
        policy.setConnectionTimeout(CXF_CLIENT_TIME_OUT);
        policy.setReceiveTimeout(CXF_CLIENT_TIME_OUT);
        conduit.setClient(policy);
        ///结束超时设置
            
        System.out.println(client.sayHello("test"));