Posted on 2008-07-18 19:11
Coolfiry 閱讀(2568)
評論(0) 編輯 收藏 所屬分類:
Java
在項目開發過程中,遇到在本機和windows環境中部署用CXF框架開發的的webService沒有任何問題,但是當將工程部署到solaris 的SUN ONE application上時,再用本機的cxf Web服務客戶端訪問對應的web服務時,如果傳輸的數據量小于大約4K不會出問題,否則則會報一些數據綁定的異常如:
Marshalling Error: Error writing request body to server。
解決這個問題花了我足足兩天時間,原因是有關CXF的資料太少了,而且有關于這個錯誤的解決都必須使用google才能search到,用baidu完全search不到相關的資料。
解決方案:
在客戶端的class-path中加上cxf.xml。cxf.xml的配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd">
<http:conduit name="*.http-conduit">
<http:client AutoRedirect="true" />
</http:conduit>
</beans>
這個問題的解決方案是我在cxf的官網上找了很久才找到的,雖然問題解決了,但是我感到很迷惑。主要在windows tomcat環境下沒有問題,而到了SUN ONE的環境就有問題,經過的思考和找了一資料,我認為問題出于solaris對于HTTP數據傳輸的某些限制,如果真要去搞清楚的話可能要去參看cxf的source code了,但是我不想花這個時間去研究這個問題了。
我把這個解決方案寫出來,希望可以幫助到使用CXF的網友,也希望高手們能幫我解決我的迷惑。