【发布时间】:2014-07-08 15:34:23
【问题描述】:
我正在使用来自 WCF 的旧 Java Web 服务,它需要以下形式的请求:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<wsse:Security mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss- wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="xxx" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-ssecurity-utility-1.0.xsd">
<wsse:Username>username</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
...
</s:Body>
</s:Envelope>
使用以下配置破解“有效”,但我不希望在配置中暴露用户名和密码:
<binding name="bindingName">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
...
<endpoint address="https://endpoint address"
binding="basicHttpBinding" bindingConfiguration="bindingName"
contract="contract"
name="bindingName">
<headers>
<wsse:Security mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss- wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-8293453" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-ssecurity-utility-1.0.xsd">
<wsse:Username>username</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</headers>
</endpoint>
我想使用的是类似的东西:
<binding name="bindingName">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Certificate" />
<message clientCredentialType="UserName" />
</security>
</binding>
但这会在安全元素中生成timestamp 元素,java 网络服务会在该元素中使用。
我需要做的是从它生成的 XML 中删除时间戳,或者使用某种自定义绑定来为我做这件事。
我尝试创建自定义凭据,但这仅更改了 usernameToken 元素。
我已经看了很多很多 SO 问题(很多是 2007 年或更早的问题),包括以下问题:
去除时间戳元素最好、最简单、最优雅的方法是什么。
提前致谢
【问题讨论】:
-
五年前刚刚从 Scott Hansleman 那里找到了这个……他们现在肯定已经修好了:hanselman.com/blog/BreakingAllTheRulesWithWCF.aspx
标签: c# soap ws-security