读书人

解决 CXF 发送soap请求时因为缺少cont

发布时间: 2012-11-14 10:12:19 作者: rapoo

解决 CXF 发送soap请求时由于缺少content-length

通过打出客户端cxf的报文信息:

lighttpd 返回"411 Length require"字样的错误。同时,在lighttpd的err日志里面,有如下的错误信息
2007-09-27 16:17:39: (request.c.1110) POST-request, but content-length
missing -> 411

?

结果确定原因是cxf客户端调用时缺少了content-length属性,需要进行如下配置:

?

Client client = ClientProxy.getClient(greeter);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = http.getClient();
httpClientPolicy.setAllowChunking(false);

?

如果是xml可以采用以下配置:

??<beans xmlns="http://www.springframework.org/schema/beans"?
? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"?
? xmlns:sec="http://cxf.apache.org/configuration/security"?
? xmlns:http="http://cxf.apache.org/transports/http/configuration"?
? xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"?
? xsi:schemaLocation="??
?????????? http://cxf.apache.org/configuration/security??
????????????? http://cxf.apache.org/schemas/configuration/security.xsd??
?????????? 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-2.0.xsd">?
?
<http:conduit name="*.http-conduit">?
<http:client AllowChunking="false">?
</http:conduit>?
</beans>?

读书人网 >XML SOAP

热点推荐