我們正在使用自定義UserNamePasswordValidator。這使得消費者能夠如下指定SOAP頭的憑據:確定WCF SOAP中客戶端的IP地址UserNamePasswordValidator
<o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" mustUnderstand="1">
<Timestamp Id="_0">
<Created>
2013-04-05T16:35:07.341Z</Created>
<Expires>2013-04-05T16:40:07.341Z</Expires>
</Timestamp>
<o:UsernameToken Id="uuid-ac5ffd20-8137-4524-8ea9-3f4f55c0274c-12">
<o:Username>someusername</o:Username>
<o:Password o:Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">somepassword
</o:Password>
</o:UsernameToken>
</o:Security>
我們需要開始記錄該客戶端的IP地址,以及做一些IP白名單/黑名單。不幸的是,我不明白在這門課程中如何檢索IP。在運行時,OperationContext.Current和HttpContext.Current屬性均爲空。
您是否嘗試過使用'HttpContext.Current.Request.UserHostAddress i'或'string ipAddress = HttpContext.Current.Request.ServerVariables [「REMOTE_ADDR」];' – MethodMan 2013-04-05 17:23:51
當在此UserNamePasswordValidator時,運行時爲HttpContext.Current爲null – csauve 2013-04-05 17:34:30
當你通過代碼並運行它時它會返回你當前的用戶名和密碼..?嘗試調試,也許你得到的異常沒有被提出 – MethodMan 2013-04-05 17:37:09