通过code的方式
Client client = ClientProxy.getClient(proxy);
HTTPConduit conduit = (HTTPConduit)client.getConduit();
HTTPClientPolicy policy = conduit.getClient();
policy.setConnectionTimeout(300000);//单位是毫秒
通过spring配置的方式
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xsi:schemaLocation="http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<http-conf:conduit
name="{http://apache.org/hello_world_soap_http}SoapPort.http-conduit">
<http-conf:client ConnectionTimeOut="30000"
/>
</http-conf:conduit>
</beans>
[1]是详细的配置信息
[1]http://cwiki.apache.org/CXF20DOC/client-http-transport.html
你说
"在jetty 的服务器上运行cxf 的客户端"
是什么意思?
java.net.SocketTimeoutException: Read timed out
这个是哪里抛出来的? 完整的exception是什么?
是指把jetty做为 servlet container使用, 把cxf service部署到里面么?
然后client 连这个service出现问题?
Freeman
1. 你的问题在我看来还是http conduit超时的问题,我比较怀疑是你的代码没有设
置对, 你能把你client的代码都提供出来么?我觉得可能是你没有把正确的http
conduit配置写到相应的client proxy上, Willem, 你的意见是什么?
2. 我不是很清楚你的wsdl接口以及怎么使用gzip压缩实现的, 一般来讲大数据的
传输我们应该用附件的形式例如mtom来传. 如果你不方便把接口和代码发到整个论
坛上, 可以直接给我或者Willem写信
Freeman
你的这种方式实际是在soap body里面传很大的二进制,但是编码格式是
base64binary, 这是一种可打印的编码格式,意味着要使用较大的空间来表示二进
制数据(通常的二进制你是没有办法打印出来的,都是乱码之类的), 如果你说数据
有十兆那就意味着你的soap body有十兆,这不是good practice
但是使用mtom 之后, soap消息中的base64binary编码可以转化为真正的二进制附
件,也就是大数据其实是以http 附件的形式来传送,我们用http都知道,附件再大也
不怕,
这个应该可以解决你传输层面超市的问题.
目前cxf支持mtom比较简单的方式是wsdl first, 你需要在想mtom格式的数据
element后边加上xmime:expectedContentTypes="application/octet- stream"
你可以看下kit中的mtom 这个例子.
如果是java first的方式,会比较复杂, 你需要自己写DataHandler的wrapper bean
并且加上annotation
例如
@XmlType
public class Picture {
private String title;
@XmlMimeType("application/octet-stream") private DataHandler imageData;
public String getTitle() { return title; }
public void setTitle(String title) { this.title = title; }
public DataHandler getImageData() { return imageData; }
public void setImageData(DataHandler imageData) { this.imageData =
imageData; }
}
如果你能到用wsdl first的方式还是wsdl first 吧