For some reason Microsoft thought it would be a good idea to only let us control the time tolerance in WSE 2.0 and 3.0 via the app.config file. ie
<configuration> <configSections> <section name="microsoft.web.services2" type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration, Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </configSections> <microsoft.web.services2> <security> <timeToleranceInSeconds>86400</timeToleranceInSeconds> </security> <diagnostics/> </microsoft.web.services2> </configuration>
This isn't always a practical option. In this case I have a DLL that needs to make a WSE web service call. Its not realistic for all my clients to add this information to their app.config files. And I am far to lazy to document it.
So enter reflection, We need to add a few lines of code to our WSE web service inherited classes constructor.
public class MyWebServicWse : Microsoft.Web.Services2.WebServicesClientProtocol { public MyWebServicWse() { Type.GetType( "Microsoft.Web.Services2.Security.Configuration.SecurityConfiguration, Microsoft.Web.Services2, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", true, true ) .GetField( "_timeToleranceInSeconds", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic ) .SetValue( null, TimeSpan.FromSeconds((double) 86400) ); //86400 == a 24 hour time span. } }
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u
Page rendered at Friday, August 29, 2008 4:18:13 AM (Pacific Standard Time, UTC-08:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.