CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Brendan Tompkins [MVP]

Blog First. Ask Questions Later.

May 2005 - Posts

  • Can Blogs be Trusted?

    Jay has been expressing his Mass Confusion... Information overload

     I'm getting all kinds of advice, but I'm not sure who to listen to at times because I really don't know who really knows what their talking about

    I left a comment to this post

    You can't be wrong on a well read blog without being told so, by people who know more than you.

    It happens to me all the time on my blog. I'm wrong, and I get set straight. In 5 years, I'll be much more right, more often. It's kind of a peer review system, and I think it works.

    In a comment, here Jay feels misunderstood

    Jay is right, there’s a lot of bad info out there (and not all of it comes from my blog), and I think I do understand Jay’s frustrations. Sure, if you do a simple Google search, and implement the first idea that pops up from a blog hit, you’ve got problems.  But I’d say you’ve got bigger problems than the big evil, anarchy of the blogosphere if you’re blindly following blog posts. When I read an unknown blog and the person is talking tech, I take it with a grain of salt.  Other blogs from people I know, I pretty much take as gospel.

    Is this a problem isolated to blogs?

    I don’t think do. When I was in grad school writing articles for psych journals, there was this one journal The Psych Record where anyone could get published if they paid a fee, and wasn’t seriously reviewed. The result? The community knew this and didn’t fully trust the content.  How was a person to know?  By being a part of the community.

    How about white papers?  They've been around forever and you really can't trust them either.  Often there's no peer review at all. Often there’s a big hidden agenda.  And you can't comment on a white paper!

    So, I don’t think this problem is isolated to blogs.  Sure, in one respect the problem is worse (everyone has a blog) but in another more important respect, the problem is much better – Everyone reads blogs too.

    I guess my point is that because blogs are heavily peer reviewed, they can be trusted, in fact, I think you can trust a well-read blog more than many other forms of communication.

    So how do you navigate the waters of the blogosphere, and find the truth?

    You learn who to trust, and who not to trust. by being involved in the community.

    So what can we do to make things better?

    Yes we can make this better! We're trying here at CodeBetter... In fact, if you read the CodeBetter.Com Manifesto, item # 2 in our bylaws is about Participation:

    Participation, Self-Monitoring and Professionalism
    Posts posted to the main feed should be relevant to software development, consulting, .NET, project management, etc.Personal posts, especially politics and religion, shall not appear on the main feed, but can be posted to your own blog. You are encouraged to subscribe to the main feed, and comment on other CodeBetter.Com posts.

    Everyone can help things by commenting on posts.  A simple “Agree” on many posts may really help us charter a more clear path.

    But don’t take my word for it.

    -Brendan

  • Web Service Thinking - Thoughts on Steve's thoughts on Sahil's thoughts...

    Sahil and Steve have been posting some really great stuff on this whole question of “What’s a Web Service.”  I’ve been trying to wrap my head around this myself with my WSMQ project, so I thought I’d add my two cents. 

    Sahil is right on the money with his post WebServices - A WHOLE new way of thinking:

    You cannot think of web services in the same way as you think of remoting, and even worse regular OOP programming. You have to wrap your head around the request/response model, understand if you ask for an event subscription - what will happen under the seams, and what effect that might have on your application.

    Thinking about services as remotable objects can lead you into some pretty dead end thinking.  I've been guilty of this myself.  In fact, it's hard not to think this way when VS really makes them look smell and feel like remotable objects.  Visual Studio may in fact be the application that brings Web Services to the rest of us, but it’s doing so at a price, and confusing us all a bit along the way.  VS should throw up a big dialog box that looks like this:

    Now, I think everyone understands this to be the case, but a dialog like this would have certainly helped me! Recently I’ve started to try to understand messaging over different transports, and the whole concept that services aren't objects really hits home when you delve into this stuff...  

    There’s also a big fat gem of wisdom to be found in Steve’s comment on Sahil’s post:

    The first and biggest mistake is believing the WebService layer exists at the business layer - bad move!

    Steve is really on to something else here, IMO.  Web services are not really services either - the way we think of them as middle-tier components (business services). In this way, I think they're mis-named.  They should be called “Message Endpoints” or Message Interface (MI) components or something else, but they're not really services!

    But back to Steve’s point, they are  more like a user interface than a service, and if they're more like UI layers, they they should be layered the same way - they should really contain no business logic and should simply be relegated to state maintenance, etc. Steve goes on to say pretty much this:

    One approach is to consider the WebService Interface operating at the same level as the WebUI level.  The request/response interaction is nearly identical, "session management" requirements are the same.

    This is something that has also taken me time to understand, but now that I do, I also understand that it’s a really important concept.

    I’ve just installed the Indigo bits this afternoon, and am really looking forward to seeing how this all fits in with the new way.  Should be an interesting next few years!

    -Brendan

  • If I were Peter Frampton..

    I'd gather you all in a big stadium,  hook up a guitar to one of those voice box thingeys, and serenade the blogosphere with a 20 minute verision of "Baby I Love Your Way":


    Do you feel like we do?
    Get back.
    Do you feel..do you feel like we do?
    Oh baby do you feel?
    Oh baby do you feel, feel like we do?
    Do you feel...do you feel...like we do?
    I want to thank you.

    Why?  Because every day, I use blogs to get my daily work done. They've become my first line of defense and a major resource for me in my day to day work.

    I’m installing Virtual PC for the first time today. I’ve been a longtime VMWare user, but since I’ve got MS VPC and all the right OSs on one DVD with my new MSDN subscription, I thought I’d give it a go.  So far, so good.

    I wanted to read up a bit on some best practices using VPC, and so I did a CodeBetter.Com search for Virtual PC.   As I sat there staring at the fact that in .012 ms, my search yielded 92 results on CodeBetter.Com, I was at once amazed and grateful for all the people out there who spend their free time blogging and creating software to enable the blogosphere.  Blogs are just a such a great resource for  what we do. 

    So, thanks everyone for reading blogs, blogging, making blogging tools and generally helping to make this community, and our jobs better.  Thanks to Telligent Systems and Scott W. for only making me wait .012 seconds for my 92 helpful blog posts. And thanks specifically to CodeBetter.Com bloggers for the following very helpful blog posts:

    -B

  • New Site Design

    You may have noticed our new CodeBetter.Com site design and logo. This is the first in a series of site enhancements here, so stay tuned!

    -Brendan

    P.S. If you're still seeing blue nav buttons, you may have to refresh your cached images.  Ctrl-F5 (Firefox users : Ctrl-R) should forces a full refresh of whatever files are cached.

  • Screen Scraping Web Forms Content with System.Net.WebClient

    Sometimes you may have the need for accessing html web content from within an application.  Why would you need to do this?  Well, suppose  you need to have a Windows Service periodically render a page with dynamic content and attach it to an email. Your application would need a way to request and save the remote page.  Perhaps you need to grab an image from a web camera and save it to a file or display it in a Picture Box within a Winforms application.  This technique, often called “Screen Scraping”  is simple (like so many other thing) with .NET. In fact, 4GuysFromRolla.com have a good article describing how to do just this: Screen Scrapes in ASP.NET.  As they describe, with a few lines of code, you can request an Internet resource and work with it’s stream.

    This uses the WebClient class in the System.Net namespace.

    The WebClient class also provides three methods for downloading data from a resource:

    A WebClient instance does not send optional HTTP headers by default. If your request requires an optional header, you must add the header to the Headers collection.

    That last sentence basically means that you can only request un-secured resources.  If the site you want to screen scrape requires cookie-based authentication, you will have to manually add the cookie header to the outgoing request, in order to be authenticated.

    Attaching a Fixed Authentication Cookie

    So how do you find out what cookie header you need to send to the remote request?  One way is to use an application like ieHttpHeaders for IE or LiveHttpHeaders for Firefox, request the resource in your browser and inspect your headers manually.  For example, if you are logged in to CodeBetter.Com, you’ll see that we set a cookie that looks something like this:

    Cookie: CommunityServer-UserCookie [bunch of text to follow]

    In order to screen scrape a secure page using the WebClient, you have to add this cookie to the WebClient’s HttpHeaders manually.  The code to do this is simple, here’s a snippet:

     
     WebClient client = new WebClient();

     client.Headers.Add("Cookie", "CommunityServer-UserCookie…");

     client.DownloadFile("http://CodeBetter.com/forums/", fileName);

    Now, attaching a fixed cookie for requesting secure data is somewhat brute-force and brittle.  If the remote site ever changes it’s machine key, for example, you’re application will break. Also, if your application needs to make requests on behalf of different users, this method will not work, because the cookie will be different for each user.

    Generating a Dynamic Authentication Cookie

    In a real-world application, to use this for anything useful, your application must know something about how the authentication cookies are generated, and it must dynamically generate the cookie to send.  In order to do this, you need to know the remote web application’s machine key (usually an impossibility, unless you control both ends) and any other custom cookie data that application sets.

    Even if you do happen know the machine key, your application needs to have web context in order to generate the cookie. Why?  Because in order to generate a cookie you must have some code like the following:


          //Create the ticket, and add the groups.

          FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket( 

            1,

            userName,

            DateTime.Now,

            DateTime.Now.AddMonths(1),

            isCookiePersistent,

            someExtraData // Our extra data (dbid, etc)

            );

     

          //Encrypt the ticket.

          String encryptedTicket = FormsAuthentication.Encrypt(authTicket);

     

          //Create a cookie, and then add the encrypted ticket to the cookie as  data.

          HttpCookie authCookie = new

            HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);

    Here’s the gotcha: the constructor for FormsAuthenticationTicket fails without a web context!  What about creating an HttpContext object manually?  Well, it turns out that there are just too many steps required to create this context manually.  The runtime goes through many steps in order to set this up properly.

    So what if your screen scraping is a Winforms application, or Windows Service? 

    In this situation, your options for generating a cookie are:

    1) Host the ASP.NET process yourself and generate the cookie.  This is messy, IMO, but if you’re interested, see Server-Side Unit Testing in ASP.NET, and Hosting the ASP.Net Runtime in desktop applications to get the gist.  It is doable, but I’d strongly recommend against it, especially if you’re worried about leaving any Alien Artifacts around.

    or 2) Connect to a Web application to request the cookie. 

    In order to do this, the best way is to expose a Web Service method which does your custom cookie generation, and return the string of the cookie for which to add to your WebClient. 

    What about security?  If you’re worried about the security risk of exposing a cookie generator via a Web Service, you could secure this service using WSE and encrypt the conversation, or better yet don’t expose this service outside of your firewall.  Remember, this service should probably accept the same credentials as your public site, and your application is generating this cookie for web users anyhow, so it’s probably not much of a security risk for you to expose this service. 

    The Code

    So what does this all look like?  Here’s an example of the sort of Web Service code that you’ll need to host to return a cookie (Note: HttpCookie is not serializable, so you can’t make this the return type of your WebService.) :

     
       [WebMethod]

       public string GetAuthCookie(string username, string password, bool isPersistent)

        {

          try

          {

            HttpCookie loginCookie = [do something custom here to generate your cookie]

            return loginCookie.Value;

          }

          catch

          {

            throw new SoapException("Not Authenticated", new XmlQualifiedName("LoginError"));

          }

        }

    And here’s the code that uses this cookie to request the secure content:

          YourAuthWebService.AuthenticationService authService = new AuthenticationService();

     

          // Get the login cookie for your site

          string cookie = authService.GetAuthCookie("[Your UserName]", "[Your Password]", false);

          WebClient client = new WebClient();

          // Your Auth Cookie can be found in the elment in your Web.Config

          client.Headers.Add("Cookie", "[Your Auth Cookie Name]=" + cookie);

          client.DownloadFile("[Your Secure Page]", fileName);


    A Bit About Keys

    One more thing to note. By default, your machine key will be set to auto generate, and different applications will not share these keys.  For your Web Service to return the same key as your Web Site, you’ll need to manually set your key using the element in your Web.Config files. See Generate Machine Key Elements for Web Farms for more on manually setting machine keys, which even contains a web based key generator.

    Finally

    Setting this up is a bear, but if you’ve done everything correctly, you should be able to download secure web content effortlessly from windows applications.  This technique can open up a whole host of applications for providing secure content.

    -Brendan

  • Bloggers have Arrived...

    I just received my much anticipated copy of James Avery's Visual Studio Hacks today.  Can't wait to get into it this weekend, but I read the credits and the list of contributers reads like my Bloglines subscriptions!  Just a few of the bloggers he mentions are Dave Donaldson, Scott Mitchell, Alex Papadimoulis, Roland Weigelt, and our very own Darrell Norton.

    This is not surprising, because James is a well-known avid blogger himself, but I was struck by all these bloggers contributing to an O'Reilly book.  I'm sure this trend will continue.  The Darrell Nortons of today, will be the Steve McConnells of tomorrow, so read 'em now.  Someday you'll be able to say "I remember when I used to read that guy blogging about which Olympic volleyball player had the nicest butt!"  ;)

    B

  • Building the WSMQ SQL Sever Database Installer

     As part of our release of the WSMQ 1.0 Beta (SQL Server Version) installer, we had to build an installer that would install our database.  In the past, I've created database installers by hand, storing SQL Scripts in resource files, and doing the logic around installation options by hand.

    With the latest version of WSMQ, I used Red-Gate's SQL Packager tool, which will completely package a database, all schema, and  user information, as well as the data, for your database, into either a C# project which you can adapt and customize, or into an .exe which you can drop into your installer project. 

    The SQL Packager packages the schema and contents of Microsoft SQL Server databases so that installing a database is much simpler. SQL Packager is used for:

    • Packaging a database structure for installation or deployment
    • Packaging database data for installation or deployment
    • Packaging both data and structure for installation or deployment
    • Updating existing databases by packaging up changes of data and structure
    • Compressing your package for reduced storage overhead and easier and faster deployment and distribution of databases

    SQL Packager does this by creating a .NET executable that can recreate the database, or the update of the database, that you need on other machines.

    David has also blogged about using SQL Packager in the past... So, suffice it to say, it really works as promised.  Something that used to take me days of coding and debugging was accomplished in less than an hour.  You gotta love that!

    -Brendan
  • My Conversation with a Crystal Guru

    A Crystal Reports consultant was in town recently for a big migration project from Crystal to Business Objects XI for the port.  I was supposed to get some face time with him at the end of his gig, so that he could enlighten me about how best to connect my .NET framework to the back-end BO server.  This guy is smart and is a really nice fellow to boot, so I felt like I could ask him some candid questions about Crystal Enterprise/BO. Here's a re-cap of our conversation, with some of the more salient parts of our discussion:

    So, how can a software company like Business Objects release a product that is so very expensive, and is so defective?

    Guru: Well, the latest version represents a lot of work to integrate Business Objects with Crystal, and they've done a good job. Many of the bugs are minor and are related to the UI, and the underlying codebase is vastly improved.

    Well, but we're still experiencing lots of bugs. Doesn’t Business Objects realize that it's hurting them to release defective software?  Why not just release a version every 3 years and insure that it has no major bugs and is well documented and it tested, instead of releasing a new version every year?

    Guru: Well, they've had to keep ahead of Cognos, so they've had to release software to keep ahead.  They’ve released too quickly, in my opinion.

    I really think the software community needs to put pressure on companies like Crystal to release better software. I think the world is waking up, and the days of very expensive, brittle software are numbered.  The majority of the products I use are generally bug free, I expect this from a software package. 

    Guru: Well Crystal Enterprise is a very complex piece of software. It has lots of components [therefore, it’s bound to be more buggy].  Other vendors release buggy software as well, just look at SharePoint from Microsoft.

    I don’t mean to be so negative, but there are lots of .NET developers like myself who have had very negative experiences with Crystal, especially in trying to deploy and manage Crystal in ASP.NET applications.

    Guru: Yeah, Crystal hurt themselves when they packaged their report engine with Visual Studio.  It wasn’t designed to be scalable.  

    Well, why would a company release a web application that wasn’t designed to scale?

    Guru: They shouldn’t have.

    I was left with this big sinking feeling that this isn’t going to change anytime soon.  Expect an under-documented, buggy release of Crystal (BI) every year or so.   Expect money to be poured into licensing for this stuff – unless more of the people involved with the software can demand a change.

    For the people who buy this stuff (the CTOs of the world) the bugs are just expected.  They’re used to spending lots of money for buggy enterprise software and I’m not sure they’ll ever really care.  Perhaps if someone could show them the true cost of implementing an enterprise reporting solution, they’d start to demand a change.  On the other hand, they’ve already budgeted the quarter of a million or so for the software, so what do they really care? 

    The report designers aren’t going to complain about the software because they have a vested interest in keeping Crystal around – their jobs.  In fact, you could argue that the more buggy the applications are, the better they get at navigating the bug-field and the more secure their jobs become.

    Sadly, it seems like as developers, we’re the only ones who are upset about buggy, brittle enterprise reporting software.  We’re  the ones who have to come in on the weekend when Crystal crashes our servers.  We’re the ones who spend three days getting the software setup, when we could be doing real work. Yeah, it’s all work for us too, so why should we care?   For one, we could be doing other things, but additionally, the high total expense of all this can cost us in our jobs.  Every dollar that a company spends on expensive software licenses is a dollar that they don’t have for paying for other software that could make your job better, consulting services and even your salary.  It’s in your best interest to save your clients or your employer money.

    When I put my idealist hat on, I do think days of big expensive software are numbered.  Better designed software will win out in the long run, but in order for this to happen, the environment needs selection pressure. We’re starting to see the industry trend toward acceptance of open source and more of a focus on how software works, and this will continue.  Hopefully this slow climate change will trickle up to the people who make these decisions. 

    And, I know it’s a crazy idea, but how about asking : “You know that $250,000 piece of software I just bought from you?  Um. Does it work?”

    -Brendan

  • WSMQ 1.0 Beta (SQL Server Version) Launch

    I’m happy to announce the start of the public beta for WSMQ 1.0 (SQL Server Version).  This downloadable beta is available to all registered users of the WSMQ site.  For more information, register at http://www.wsmq.com.  

    About WSMQ

    Web Service Message Queue (WSMQ) is a simple message queuing alternative for enabling reliable, professional-grade applications. Compared with other popular message queues, WSMQ is easier to deploy, write code for, manage and scale.

    New Service Features:

    All peek and receive methods have been expanded with versions that return a QueuedMessage object that contains the QueuedMessageId.  This allows for operations that first peek messages on the queue and then receive by message ID, allowing for greater reliability within a queue operation.

    All methods have been changed to allow a QueueRequestId that can be set to guarantee that multiple requests with the same QueueId do not have any cumulative effect on the state of a queue.

    Back-end Queue Storage is now in SQL Server, resulting in large performance gain over the file system version.  We are launching the File System Version beta in the next week.

    New Queue Admin Web Application Features:

    Added the ability to search messages on a Queue or Journal, or within an Archive or Dead Letter Queue.

    Added user Management Features

    Added an Admin Queue, and administration level access to all end-user queues.

    Numerous UI enhancements.

    Pricing, Restrictions and Future Plans

    The beta version will function until August 31st, 2005, by which time we will have a Beta 2, or release version.  We are currently exploring pricing options, which we will announce before the expiration of this beta. The release version will be available with source code included.  If you have questions, concerns, or suggestions about pricing, please contact me off-line at brendan.tompkins@gmail.com for more information.

    WSMQ Hosted Version

    We are continuing to evaluate the viability of the hosted version of WSMQ.  As a beta participant, you are granted access to the hosted version of the queue.

    Thanks! 

    -Brendan

More Posts

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News

MVP
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.