2012-05-02 28 views
3

我們開發了一個WCF4服務,該服務使用由Java/Axis客戶端(我們無法控制)使用的usernameToken身份驗證。WCF響應中的MustUnderstand屬性導致Java/Axis客戶端錯誤

我可以看到該請求的身體看起來像這樣來了...

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soapenv:Header> 
    <wss:Security xmlns:wss="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
     <wss:UsernameToken> 
     <wss:Username>username</wss:Username> 
     <wss:Password>password</wss:Password> 
     </wss:UsernameToken> 
    </wss:Security> 
    </soapenv:Header> 
    <soapenv:Body> 
    {snipped} 
    </soapenv:Body> 
</soapenv:Envelope> 

,我們正在返回看起來像這樣的反應...

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
    <s:Header> 
    <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
     <u:Timestamp u:Id="_0"> 
     <u:Created>2012-05-02T01:23:12.711Z</u:Created> 
     <u:Expires>2012-05-02T01:28:12.711Z</u:Expires> 
     </u:Timestamp> 
    </o:Security> 
    </s:Header> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    {snipped} 
    </s:Body> 
</s:Envelope> 

的問題是響應中的s:mustUnderstand =「1」屬性。這導致Java/Axis客戶端中的「必須瞭解檢查失敗」錯誤。

有誰知道如何配置WCF刪除此s:mustUnderstand屬性或至少將其設置爲「0」而不是「1」?

+0

這是否幫助? http://stackoverflow.com/questions/3551738/how-to-modify-a-wcf-message-headers-mustunderstand-using-clientinspector – Chris

+1

你的安全配置是什麼?也許從配置中刪除時間戳可以解決問題。否則,你將不得不實現自定義消息編碼器來修改頭。 –

回答

1

我們想出來解決這個互操作問題的解決方案是更改爲自定義綁定並指定includeTimestamp =「false」屬性。通過這樣做,時間戳(創建和過期)不會被添加到響應中,因此整個安全標頭消失 - 包括導致所有問題的mustUnderstand屬性。

<customBinding> 
    <binding name="customBindingConfig"> 
     <security authenticationMode="UserNameOverTransport" includeTimestamp="false" /> 
     <textMessageEncoding messageVersion="Soap11" /> 
     <httpTransport /> 
    </binding> 
</customBinding> 

所以響應,現在只是看起來像這樣...

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
     {snipped} 
    </s:Body> 
</s:Envelope> 
+0

您是否有服務的service.xml中指示的時間戳? –

+0

@布萊恩,我不知道。幾個月前我離開了公司,因此無法訪問源代碼 - 對不起! – barrylloyd

相關問題