2016-04-15 22 views
1

我想從http出站網關發送此字符串「de caisse aété enregistr ***é***」。此字符串包含法語字符(é)。我得到一個響應代碼爲400(錯誤的請求)的錯誤法國字符像é不支持春季整合http出站網關

但是,當我嘗試從休息簡單的客戶端框架相同我得到一個成功的代碼(200)。

在我的彈簧集成配置中是否存在缺少的東西。 ?

共享配置

<int-http:outbound-gateway id="xtifygateway" 
 
          
 
\t \t request-channel="xtifyrequestchannel" request-factory="requestFactory" 
 
          
 
\t \t url="${xtifyUrl}" http-method="POST"> 
 
    
 
    </int-http:outbound-gateway> 
 

 

 

 

 
<int:header-enricher input-channel="requestchannel" 
 
        output-channel="xtifyrequestchannel"> 
 
<int:header 
 
     name="Content-Type" 
 
     value="application/json"/> 
 
     </int:header-enricher 
 
    
 
    
 

 
<bean id="requestFactory" 
 
\t \t class="org.springframework.http.client.SimpleClientHttpRequestFactory"> 
 
\t \t <property name="connectTimeout" value="${timeout}" /> 
 
\t \t <property name="readTimeout" value="${timeout}" /> 
 
    \t </bean> 
 

 

 

+0

如果您使用wireshark跟蹤您的請求並相互比較,會更好。請介意在400代碼之後分享堆棧跟蹤?請求中沒有服務器的內容?也許你剛剛錯過了一些HTTP標頭,這是Rest Easy的默認設置... –

+0

另一方面:你還沒有確認它的工作原理沒有法國字符......所以,意外字符的問題不是明顯。 –

+0

Artem,我將在週一分享堆棧追蹤。沒有法國字符,一切工作正常。 – chungunuvavaa

回答

0

改變從字符集UTF-8在Java代碼ISO-8859-1解決問題。

try 
    { 
     message= new String(message.getBytes("UTF-8"),"ISO-8859-1"); 
    } 
    catch (UnsupportedEncodingException e1) 
    { 
     // TODO Auto-generated catch block 
     e1.printStackTrace(); 
    } 
1

你應該嘗試設置的字符集

<int-http:outbound-gateway id="xtifygateway" 

request-channel="xtifyrequestchannel" request-factory="requestFactory" charset="UTF-8" 

url="${xtifyUrl}" http-method="POST"> 

    </int-http:outbound-gateway> 
+0

定義字符集是不是解決問題.. – chungunuvavaa

+0

它是這樣的默認:'私人易變的字符集字符集=字符集。的forName( 「UTF-8」);' –