我们正在使用自定义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