2016-07-12 35 views
0

嘗試使用apache cxf 3.1.6和java 8使用SOAP服務時,通過更改有效內容內容,我得到'200 OK'或' 403禁止'。獲取403:在java中使用apache cxf使用SOAP服務時禁止使用

奇怪的部分是,如果我打印出有效載荷並放在SOAPUI上,那麼我總是得到200 OK。

您是否遇到類似問題?如何解決這個問題?

+0

這意味着您無法連接到端點,它可能無法激活。 –

回答

2

所以,你不會像我這樣的日子陷入困境,撓撓腦袋,思考爲什麼發生在心臟,這裏是解釋的問題和解決方案。

發生此問題是因爲默認情況下,apach cxf使用「Chunking」,一旦達到定義的閾值,基本上會將小塊數據發送到端點。這導致SOAP消息在未完成時發送,導致'403'(假定服務器不支持'分塊')!解決的辦法是禁用 「分塊」,通過改變彈簧config.xml中:

<http-conf:conduit name="*.http-conduit"> 
<http-conf:client Connection="Keep-Alive" 
        MaxRetransmits="1" 
        AllowChunking="false" /> 

附加信息:

上org.apache.cxf.transport.http.HTTPConduit,對於「準備」方法存在以下所有內容:

// DELETE does not work and empty PUTs cause misleading exceptions 
     // if chunking is enabled 
     // TODO : ensure chunking can be enabled for non-empty PUTs - if requested 
     if (csPolicy.isAllowChunking() 
      && isChunkingSupported(message, httpRequestMethod)) { 
      //TODO: The chunking mode be configured or at least some 
      // documented client constant. 
      //use -1 and allow the URL connection to pick a default value 
      isChunking = true; 
      chunkThreshold = csPolicy.getChunkingThreshold(); 
     } 
     cookies.writeToMessageHeaders(message);