Monday, May 22, 2006

I'm developing a web service in ASP.NET 1.1 through which I need to transfer files.  There are a myriad ways in which I could accomplish this, but rather than roll my own, which I am sometimes inclined to do, I wanted to use some built-in functionality.  This functionality can be found in WSE 2.0 and DIME (Direct Internet Message Encapsulation) - thanks Fabio for reminding me.  Believe me, it pains me that I cannot use WSE 3.0 and MTOM with .NET 2.0, but such is not possible with this project - at least not yet.  But transferring the files would be orders of magnitude easier via MTOM, but alas, here we are.

Shortly after I set up the web service and tested it locally, I wanted to ensure that it would work remotely.  The machine to which I have it deployed is running on a Virtual PC running Windows Server 2003.  I could see the nice ASP.NET web service description page navigating via my browser to the .ASMX file, but when I attempted to access it via code, I was first presented with the following error message:

System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
...

Oh, that's right, I need to include some credentials to access this particular web service.  Therefore, I added the following snippet of code below my client proxy declaration:

ServiceWse svc = new ServiceWse();
svc.Credentials = CredentialCache.DefaultCredentials;

Once I did that and ran my test harness I was greeted with a slightly more inocuous error:

Microsoft.Web.Services2.Security.SecurityFault: An error was discovered processing the <Security> header ---> System.Exception: Creation time in the timestamp can not be in the future.
--- End of inner exception stack trace ---
at Microsoft.Web.Services2.Security.Utility.Timestamp.CheckValid()
at Microsoft.Web.Services2.Security.Utility.Timestamp.LoadXml(XmlElement element)
at Microsoft.Web.Services2.Security.Utility.Timestamp..ctor(XmlElement element)
at Microsoft.Web.Services2.Security.Security.LoadXml(XmlElement element)
at Microsoft.Web.Services2.Security.SecurityInputFilter.ProcessMessage(SoapEnvelope envelope)
at Microsoft.Web.Services2.Pipeline.ProcessInputMessage(SoapEnvelope envelope)
at Microsoft.Web.Services2.InputStream.GetRawContent()
at Microsoft.Web.Services2.InputStream.get_Length()
at System.Xml.XmlScanner..ctor(TextReader reader, XmlNameTable ntable)
at System.Xml.XmlTextReader..ctor(String url, TextReader input, XmlNameTable nt)
at System.Xml.XmlTextReader..ctor(TextReader input)
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
...

As it turns out, WSE will utilize a timestamp to verify security tokens between the SOAP sender and receiver and if the two computers' clocks vary by more that the default tolerance of five minutes, it will fail.

One solution would be to synchronize the client to the server, but that's a pain and may not properly work in a global scale which would be required by my particular application.

This baffled me for a few minutes because the time on my local PC and the time on my VPC were the same; that is, they appeared the same.  I quickly saw that the VPC's time, though the same with respect to hrs, minutes, and seconds is relative to Pacific Time whereas my laptop is on Mountain Time.  So they ultimately varied by 60 minutes, well over the default tolerance.

The solution is to alter the web.config file on the server and the client application's configuration file to include an override to the tolerance.  I set it to allow for up to a day (24 hrs) in difference to accommodate for any discrepancy that may arise.

<configuration>
   <configSections>
      <section name="microsoft.web.services2" type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration, Microsoft.Web.Services2, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
   </configSections>
   <microsoft.web.services2>
      <security>
         <timeToleranceInSeconds>86400</timeToleranceInSeconds>
      </security>
   </microsoft.web.services2>
</configuration>

I'm actually very happy that I had this situation arise now rather than after I had deployed because I now remember that I have to test for time zone differences.

Monday, May 22, 2006 9:29:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [3]  |  Trackback

Resharper 2.0 was released by JetBrains today!  I have been anxiously awaiting this release since November of last year at the debut of VS 2005.  Being an avid fan of Resharper 1.0 - 1.5.1 for VS 2003, I was very excited about the prospect of getting similar yet advanced functionality in both VS 2003 and VS 2005.  Well, today (finally) the wait is over.

I've since downloaded them (both versions) and am in the process of installing.  The VS 2003 installation went smoothly and without a hitch, but the VS 2005 is taking a LOOOONG time during the application of some VS.NET hotfixes.  Anyone else have similar issues?  It's not like the sitting there idly, though the installer does indeed look stalled - it's not providing any feedback whatsoever.  I'm using FileMon and Process Explorer to watch the installation and it is indeed working, it's just taking forever and the UI doesn't give any feedback.

Monday, May 22, 2006 4:33:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [1]  |  Trackback
 Tuesday, May 16, 2006

If you're creating a Web Service and you run across an error that resembles this:

Server Error in '/MyVirtualDirectory' Application.

Parser Error
...
Parser Error Message: Could not create type 'xxx.MyWebService'.

Don't worry, it's not that difficult to fix.

First of all, make sure your website is indeed within a Virtual Directory running the proper version of ASP.NET.  This can be ascertained in IIS.

Barring that, make sure you have deployed your website's DLLs into the proper \bin directory.  I ran into this error because my virtual directory is actually housed within another virtual directory/site that had it's own assembly references and I had removed them in my web.config like this:

<compilation defaultLanguage="c#" debug="false">
   <assemblies>
      <clear />
   </assemblies>
</compilation>

Once you do that, you effectively lose reference to your own DLLs.  Simply add yours back, along with the others you need (Web Services will require System.Xml and System.Web.Services).

Your web.config file may resemble this for ASP.NET 1.1:

<compilation defaultLanguage="c#" debug="false">
   <assemblies>
      <clear />
      <add assembly="System.Xml, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" />
      <add assembly="System.Web.Services, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null" />
      <add assembly="My web service dll here" />
   </assemblies>
</compilation>

 

Tuesday, May 16, 2006 3:11:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [5]  |  Trackback

I meant to blog about this a few weeks ago, but was reminded today that I had not yet done it.

On Wednesday, May 31st, Microsoft will be hosting a PASS (Professional Association for SQL Server) Code Camp which looks to be a lot of fun and very exciting.  The event is free and open to all, but you are requested to register.

To properly cite:

Utah PASS SQL Code Camp
Wednesday, May 31, 2006
Microsoft Offices
Salt Lake City, UT

PASS Camp is a Free one day SQL Server community building event being presented by PASS and the Official PASS Chapters Salt Lake City and Utah County SQL Users groups. These will be short and in-depth sessions to learn about SQL 2000 and SQL 2005.Visit the website below for more information and to register.

http://utpasscodecamp.mollyguard.com

Hope to see you there!

Tuesday, May 16, 2006 2:08:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Monday, May 15, 2006

I found this handy little tip today when I had to send CTRL+ALT+DELETE to a remote desktop session (which always ends up being processed by the local machine and not the remote one).  The keystroke is CTRL+ALT+END.  Handy to know and remember!

Monday, May 15, 2006 8:02:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [52]  |  Trackback
 Thursday, May 11, 2006

Tonight's Utah .NET User Group meeting was awesome.  We had a great turnout and had a blast.  We had several new faces too which is always delightful.  Tonight I had the opportunity to present on the topic of Windows Services.  We touched on several aspects of Service creation, debugging, and ultimately created a simple Windows Service that would effectively 'ping' a website to keep it 'hot'.  We didn't take it to the level of 'pinging' the website on a given interval though that would have been easy to do.  Instead, we have the service monitor the website's web.config file.  When the file changes, it pings the website, requesting a designated page.  Essentially, this helps remove the 'first-time' load on the next request when the IIS process recycles.  It could easily be enhanced to monitor a set of user-designated files and keep multiple websites alive and also 'ping' the websites on a given interval.  You can download the source that I created during the presentation here.

All in all, it was a great event and several of us got together at the Denny's on 106th South and I-15 afterwards to hang out and have a good time.  How fun!

Thursday, May 11, 2006 5:50:00 PM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Wednesday, May 10, 2006

I have the opportunity later on tonight (now that it's past midnight I can say that) of presenting at the Utah .NET User Group.  This presentation will be the third in a series focused on component development.  The preceding two talks have focused on control development, specifically Windows Forms Controls and ASP.NET controls.

This go-around, however, we'll be talking about Windows Services and the SCM.

If you're in the neighborhood, please come on by and enjoy free pizza and a fun presentation.  Hope to see you there!

Date: 05/11/2006
Time: 6:00 PM
Place: Neumont University, Suite 300 (10701 South River Front Parkway, South Jordan, Utah)

Wednesday, May 10, 2006 5:27:00 PM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback

A Web Garden Box is something completely different.  Actually, this is manual labor - something I really enjoy - especially after sitting in front of a computer all day.  I took Monday and Tuesday off last week and got to projects around the house.  One of my projects was to build a box around the garden area.  Long have I wanted to to this, but I finally took it upon myself to actually get it done.

I went out and purchased a flat-bed trailer ('cause I sick and tired of leaning on my brothers to help me haul wood), hitched it up to my SUV (had to put a hitch on it first), and hauled home the redwood, cement, and stuff.  I then set out to assemble it.  Granted this was an extremely easy thing to design and build, but I revel in it, and had a great time doing it.

All in all I'm pleased with the result.  There're just a few more things to do.  I'm going to seal it this weekend and line the interior with some plastic or landscaping cloth.  Also, as you can see from the image that I subdivided the garden into three areas.  I'm going to run some PVC all the way across and T off of it in each box and run some perforated tubing through each section individually.  I'm also going to take the router and do a 1/2” round over on the lip that goes around the box just for esthetics.

Wednesday, May 10, 2006 7:56:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [2]  |  Trackback
 Monday, May 08, 2006

Microsoft released today the Visual Studio 2005 Web Application Projects for Visual Studio 2005 (obviously).  I've been running on the betas and RC1 of the product since it came out and I've just upgraded to the release.  If you like the VS 2003 / ASP 1.x programming model but would like to take advantage of the 2.0 Framework and the coolness of Master/Content pages and much more, check it out!

http://msdn.microsoft.com/asp.net/reference/infrastructure/wap/default.aspx
Monday, May 08, 2006 12:47:00 PM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback

If you're like me and have both ASP.NET 1.1 and 2.0 on your machine (along with the associated Visual Studio 2003 and 2005 products because you can't help but write software in both environments) you may encounter this issue.  Upon running your website (via http://localhost/xxx or something like that), you may encounter the error page that reports:

Failed to access IIS metabase

If so, you may have installed IIS after installing the .NET framework.  If that's the case, try running to repair your ASP.NET installation and set up all of the appropriate ISAPI extension mappings.

aspnet_regiis -i

If, however, you're like me and had IIS already installed, and you installed VS 2003 and then VS 2005, and then set up a 1.1 virtual directory / website, simply check that the appropriate ASP.NET version is associated with it (Select VDIR --> Properties --> ASP.NET tab).

Monday, May 08, 2006 9:40:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [221]  |  Trackback
 Friday, May 05, 2006

I just had the opportunity to attend a webcast presented by Scott Hanselman entitled “MSDN Architecture Webcast: Introduction to Programming Hardware with the .NET Framework 2.0“.  What a cool presentation., Scott was up to his usual great form when it comes to presentations, despite a few sharing glitches which were easily ignored.

Scott touched on many things new to .NET 2.0 most notably interfacing with serial ports.  Additionally, he addressed using USB devices.  His demos (which are fully available online) included receiving information from a USB GPS device (the one included with Streets and Maps), pushing data to an LED (in this case, showing what Media Player is playing), using a USB Wireless Security FOB, using WIA (Windows Image Aquisition) to receive images from a WIA-enabled webcam, and more.

If you missed it, it should be available in a recorded form on Microsoft's site within 24 hrs.

Thanks, Scott!

Friday, May 05, 2006 5:20:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback

Mark Russinovich, the brilliant co-mind behind of SysInternals and author of a vast array of extremely helpful utilities, just published a new utility that has already found a comfortable home among those utilities that I use on a daily basis.  This new one is called AccessChk.  This awesome tool will help you secure your system by allowing you to verify the kinds of access permissions that a user has (be they read or modify permissions) for files, directories, Registry keys, and Windows services.

I've been wanting a tool like this for some time, but never took the time to write anything.  Thanks, Mark, for yet another ultra-uber-helpful utility.

Speaking of helpful utilities, does anyone know of one that does the following?  I have long wanted an easy way to see a utility that I'll call PolicyChk which I could use to see which Group Policies a user/group has rights assigned (either directly or via group membership).  There have been times uncountable wherein I wanted to grant a user the same polciy rights as another user (such as ASPNET), but didn't know which rights to assign without laborious manual examination of the various policy settings looking for the account and it's various group memberships.

Friday, May 05, 2006 4:40:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, May 04, 2006

It's been a crazy week!  Hardly any time for blogging, unfortunately.  I've been setting up my new Dell Precision M90 laptop :-) as well as doing TONS around the house.  Not to mention that I took Monday and Tuesday off (something I haven't done for a long time, too long).

I took the time to enable HTTP Compression on my various websites, this blog among them.  Hopefully performance is better all around.  Let me know if there are any issues or if you experience any outages.  There are many great references out there for successfully enabling compression in IIS.  I found this one, and this one, oh, and this one to be pretty doggone helpful.

Thursday, May 04, 2006 7:01:00 PM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback