Paul Mendoza C# blog
Saturday, January 27, 2007
  Extending the Windows Vista trial to 120 days from 30 days
Windows Vista is the .NET developers platform. It supports .NET from the start and in the coming years I believe Windows Vista will be what causes many developers to start switching development from the standards Windows API's over to .NET and it's libraries as the install base grows.

With that though, I'm sure there are still many developers that just haven't got around to upgrading to Vista so Coding Horror had this great post on how to extend the Windows Vista trial to 120 days which is 90 days more than the original trial allows. I don't actually know if this was intentional by Microsoft and this will be fixed with a patch later but hopefully this remains a feature.

No hacks required. This is an official, supported operation directly from Microsoft.

To extend the grace period another 30 days, simply start a command prompt as Administrator, and issue this command:

slmgr -rearm
Reboot for the change to take effect, and voila, you have 30 more days. You can only extend three times, so the total grace period for a Vista evaluation is 120 days. You do, however, need to be careful that you've installed the correct edition of Vista. At the end of that 120 day grace period, you'll have to pony up a license fee for the edition of Vista you've installed.


I will definitely be trying this in the next week or so. Now all I need to do is find a link for the download of Windows Vista trial.
 
  Beating Google search engine results like Paul Mendoza!
Lately I've become interested with where I rank on Google for searches. For a long time, I was interested with one particular metric and it was the search for "C# blog" and whether or not I was on the first page. For Google I sit right at the top of the second or sometimes the bottom of the first page. I really don't know what changes this on such a daily basis although I think it's based on which server is serving the content to me.

But I've come across some handy sites and things you should try for your blog or website if you're interested in this as well.

Google PageRank

First, find out what your website's Google Pagerank is. Google PageRank is how Google identifies how important your page is. I'm actually sure that there are decimals for this value but it's on a 1 - 10 scale, 10 being the most popular. My blog rates about a 5 as well as FilePhantom.com but they're linked to by other websites.

Links

Google rates your site's importance based on how many people are linking to it.

For my blog though, anytime I make a comment anyplace on the internet, I always make sure to include a link back to my website. I don't actually know if Google has technology do differentiate a comment link and a non-comment link but I always make sure to link back to my blog. I'm hoping that this has some sort of impact on my Google rating.

Google Webmaster Sitemaps

Google Webmaster sitemaps tool is a great tool to analyze the performance of a site in Google in depth down to the level of seeing where dead links are in a site, page performance, queries people use when they find your page and a whole bunch more. I found this about two weeks ago and I find myself checking it far too often trying to figure out why someone found my site one way and not another way.

Finally....

Write on topics that people are searching for the most

If I find I'm getting a bunch of traffic for a particular blog post, I try to write another blog post on that same topic but with a different twist. Content is king and this strategy generally seems to work for me.

So what works for you?
 
Thursday, January 25, 2007
  Example.com for developers
I was reading through some of .NET Slave's old posts and he had a post on domain names that are used while developing sites that are used as fillers. Apparently Example.com is a reserved domain name for developers such that going to the website http://www.example.com results in a page that says it's a development page. I suggest you check out his blog post for more information on this cool Internet feature.
 
Wednesday, January 24, 2007
  AJAX for the masses

The simpler something is to do for developers, the more developers that will pickup the skills to do it. We have reached a point I believe in which it has become incredibly simple for the majority of web programmers to quickly design complex AJAX features for pages quickly and easily.

AJAX has been relatively difficult for most web developers to create. Either you need to learn a totally new language to have good support like Ruby on Rails which really is a whole framework in and of itself or you need to know how to program in JavaScript as well as whatever backend coding you do. Finding an advanced JavaScript coder that is also skilled with the backend coding that is required to implement AJAX features if often difficult if nearly impossible for most companies to find.

But with the release of Microsoft’s AJAX toolset yesterday, a programmer working on a web application now doesn’t need to know any JavaScript in order to get the AJAX features working quickly in their existing applications. What this means is that in the coming months, many websites that don’t had the budgets to do R&D into AJAX like Google, Yahoo and Microsoft have will now be able to easily and quickly upgrade their existing ASP.NET applications to use many new AJAX technologies without having to hire AJAX experts.

As a result of this ease of use, Microsoft’s investment in AJAX may have been the best technology investment they have made in a while. In order to use Microsoft’s AJAX libraries, the web application must run on IIS using ASP.NET pages. IIS has to run on a Windows machine and as a result, developers are going to want to use Microsoft’s ASP.NET technologies which in turn are going to sell more and more of their Windows Server machines.

At this point from what I’ve seen, no other web development framework offers the level of AJAX support that ASP.NET now offers and none of them probably will for at least six months while they try to catch up to it’s features. While most frameworks do offer some good but basic level of support for simple AJAX page features, almost none offer the number of features that the new Microsoft AJAX Control Toolkit offers. The result of using these new tools is clean code that lacks massive amounts of messy JavaScript to do the types of features which used to take pages of code which can now be accomplished in just a couple lines of code with the Microsoft AJAX tools. This is highly appealing to developers building large and small websites.

In the coming years, if Microsoft includes a tighter integration of their AJAX solutions into their ASP.NET web solutions, this could be as big of an advancement as HTML was to websites.

 
Tuesday, January 23, 2007
  Did you know? ASP.NET AJAX was released

I feel like I was just spammed on my RSS reader about the release today of ASP.NET AJAX. The screenshot on the left is a picture from Google Reader of some of the feed titles. Since I subscribe to a pretty large number of .NET developers and apparently ASP.NET developers, today was pretty eventful for them I guess. I looked over the release though and it doesn't really seem like anything new has been added to the release between the last version and the new release version that makes me think there is anything that special going on.

I've actually been very happy so far with the ASP.NET AJAX libraries that were in beta so for the last few months as I've had almost no issues with them at all. If you haven't had a chance to try the ASP.NET AJAX libraries, I highly recommend you try it out. It's incredibly simple compared to some others that are on there and if you're actually creating your own JavaScript, the new libraries and tools are incredibly simple to use in comparison. Now, it's not incredibly simple to setup and integrate but it's leaps and bounds beyond manually doing it with JavaScript.

Here is a neat little suggestion for you when you're starting to work with it. Just put your ScriptManager control that every AJAX using page needs in the Master Page for your site. That way you don't have to declare it on every page. Although this may incure a slight overhead to the page, it's probably minimal.



And if you want an awesome sample, David Barkol posted a great little sample site that he made using the new ASP.NET AJAX extensions. It's a very good sample site for the types of things you can do quickly with ASP.NET AJAX and he gives out the code for it as well.
 
Monday, January 22, 2007
  Shipping isn't enough
I have been working a little bit recently on the new version of File Phantom but I've been working way way way more on the currently released version but I'm not creating bug fixes for it or creating patches. I'm working on marketing or better documentation or the website for the product or refining the payment system to handle the transactions better or any number of mundane, back end tasks that no one is going to be awesomely impressed with but it's a part of the process of launching code. When I started building File Phantom, I did it because I thought it would be a cool programming project to work on. I do very little programming for File Phantom compared to what I used to do. It's all part of what it takes to create a product and ship it and then support it.

Coding Horror has a great post on shipping code. He writes...

A smart software developer knows that there's no point in writing code if it's code that nobody will see, code that nobody will use, code that nobody will ultimately benefit from. Why build a permanently vacant house?

A smart software developer realizes that their job is far more than writing code and shipping it; their job is to build software that people will actually want to use. That encompasses coding, sure, but it also includes a whole host of holistic, non-coding activities that are critical to the overall success of the software. Things like documentation, interaction design, cultivating user community, all the way up to the product vision itself. If you get that stuff wrong, it won't matter what kind of code you've written.

If, like Rich Skrenta, you want to work on software that people want to use, realize that it's part of your job to make that software worth using.

But if you don't have good code, the rest is all for nothing.
 
  Flickr success from Tara Hunt
If you don't read Tara Hunt's blog and you're building some sort of web application or trying to figure out how to market one, you're really missing out. She's probably one of the premier bloggers on Web 2.0. She wrote an awesome article today on Flickr and their success that you should check out as well.

This is a website. A website. A mere tool!

But is it?

Flickr has mojo. They have alot of it. In fact, the site oozes it…but it isn’t really the layout or much of anything to do with the programming…that’s just a part of it. It’s everything that goes into it. When I started to use Flickr in early 2005, I could feel the “soul” of the site instantly.


Read the rest
 
  Long default document lists really slow IIS for default pages
I find this to be amazing. I never realized that IIS worked like how Thomas Deml describes but I'm going to be making sure my web applications are optimized tonight probably for this.

IIS will read the default document list and check file for file if the document exists in the physical directory of your site or vdir. IIS executes the document as soon as it finds the first match. You can imagine that this is pretty expensive. In the above case, supposing default.htm is the only default document that exists in your sites root directory, IIS would check five times until it finds default.htm. And this happens for every request!


Read the blog post
 
Sunday, January 21, 2007
  File Phantom is finally on Bits Du Jour

File Phantom is on Bits Du Jour right now with only 22 hours and 22 minutes left on the sale for the software which is selling for the highly discounted price of $15.98. For about the last month, maybe more, even before we were launching the product back in December, our goal was to get File Phantom on Bits Du Jour and I'm very glad that we've finally got the product on the website.


If you haven't had a chance to check out File Phantom, there is a demo on the File Phantom website that can be downloaded but make sure that if you like the product you buy it today otherwise you will need to pay the full price later for it which is normally $39.95.
 
  53 CSS Techniques You can't live without
Smashing Magazine blog just created this awesome list of 53 CSS techniques that looks like it will come in quite handy later on.

Over the last few years web-developers have written many articles about CSS and developed many useful techniques, which can save you a lot of time - of course, if you are able to find them in time. Below you’ll find a list of techniques we , as web-architects, really couldn’t live without. They are essential and they indeed make our life easier. Let’s take a look at 53 CSS-based techniques you should always have ready to hand if you develop web-sites.

1. CSS Based Navigation

2. Navigation Matrix Reloaded

3. CSS Tabs

Read the rest....
 
  Refresh ATLAS AJAX UpdatePanel via Javascript
I just saw this excellent little post by Raj Kaimal on how to refresh an Microsoft AJAX (formerly ATLAS) UpdatePanel by using JavaScript. If you use Microsoft AJAX, this is a great blog to subscribe to. Raj Kaimal has some really useful advice on implementing Microsoft AJAX features.

At some point if you're working with the UpdatePanel, you're going to want to do this. I once needed to do a bunch of processing on a server and I wanted the page to check the server every couple of seconds to see if the actions had been completed yet but I didn't want to reload the entire page each time so I used something like this.

I have seen this asked a couple of times in the newsgroups hence this post. A simple way of refreshing an UpdatePanel using JavaScript is to add a HiddenField to the page, change its value using JS and then have the HiddenField raise a postback event...

Read the rest from Raj Kaimal's blog
 
  IE Developer Toolbar beta 3 released
I've been using the Firefox developer tools called Aardvark Firefox extension for the last six months while doing HTML coding and I've found it extremely useful for analyzing a page I've created of the pages of other developers.

It sounds like IE may have created another tool that might be more useful to HTML and CSS coders though for their browser which I'm very excited about. It's called the Internet Explorer Developer Toolbar and it's in it's third beta. It's still in beta and it's not stable yet so it probably shouldn't be installed for production use but it's something to be aware of.


The Internet Explorer Developer Toolbar provides several features for exploring and understanding Web pages. These features enable you to:


  • Explore and modify the document object model (DOM) of a Web page.
  • Locate and select specific elements on a Web page through a variety of techniques.
  • Selectively disable Internet Explorer settings.
  • View HTML object class names, ID's, and details such as link paths, tab index values, and access keys.
  • Outline tables, table cells, images, or selected tags.
  • Validate HTML, CSS, WAI, and RSS Web feed links.
  • Display image dimensions, file sizes, path information, and alternate (ALT) text.
  • Immediately resize the browser window to a new resolution.
  • Selectively clear the browser cache and saved cookies. Choose from all objects or those associated with a given domain.
  • Choose direct links to W3C specification references, the Internet Explorer team weblog (blog), and other resources.
  • Display a fully featured design ruler to help accurately align and measure objects on your pages.
  • Find the style rules used to set specific style values on an element.
  • View the formatted and syntax colored source of HTML and CSS.

The Developer Toolbar can be pinned to the Internet Explorer browser window or floated separately.

This Beta 3 version of the toolbar contains functionality and stability enhancements over previous versions, including:
  • Style Tracer: Right mouse click on a style value for an element and select Style Tracer to find the style rule that is effecting that value.
  • CSS Selector Matches: View a report of all style rules set and how many times they are used on the current page.
  • View Source: View the formatted and syntax colored source of the original page, currently rendered page, element or element with the styles that are effecting it.

Download here
 
Friday, January 19, 2007
  OOXML standard has problems with date the year 1900

Microsoft released a 6,000 page standard for their new Office XML format, also known as OOXML. From what I’ve read about the process to get it approved, it’s going to take about six months and that’s rushed. So the standard which they are releasing in their software will be approved months after their product actually ships.

And now get this! The standard has some problems with it that I think should have been fixed before it was released to the approval process. One example is the year 1900 and leap years as O'Reily writes on his blog. Can this actually get through the approval process? I’m curious what happens if it doesn’t make it through the approval process? Will Microsoft modify any of it in order to get it to comply with the requirements for approval? What would that mean for the versions of Office they have already released to the market?

There is a good summary of what some of the issues with it are right now here.

On the leap year issue, I think this was also something the Joel on Software worked on at Microsoft as a manager on Excel. He even met with Bill Gates on the topic and it was the hardest question Bill Gates could ask Joel. It's actually a pretty entertaining read.

 
  Finding beta testers

MyMicroISV has some great tips today on getting people to test your software beta. I experienced some issues with this when I was developing File Phantom during it’s beta period but I found many of my beta testers in my circle of friends and online contacts. This isn't always the best way to find beta testers though because friends and family aren't always the target market for the product you may be building. It could have been for File Phantom so I was glad they were testing it and I received a lot of really good feedback from those that were able to beta test.

Be sure that if someone does beta test your software and finds a bug that's good, make sure that when you finally release the product to at least give them a free copy of your software because hopefully they'll tell others about what you've built and will also beta test it again later.

My favorite point that he makes is the following.

Make getting the beta as painless as possible. That means no registration form, no required email, no hoops to jump through. Your beta is competing for attention against a thousand others. Beta testers are doing you a huge favor - you owe them, not the other way around.

Read the rest

 
Thursday, January 18, 2007
  Number formatting with localized ASP.NET applications

A while back Mads Kristensen released a pretty handy tool that I’ve been using for tracking the uptime of my web servers and he wrote a great entry today on his blog about localized ASP.NET applications and how they format numbers.

The number two thousand decimal one two five is written differently in the various cultures. Here are some examples

1000,125 (European)
1000.125 (American)

Imagine that you have to parse XML files wherein the number format is European and you do it from an ASP.NET application with the culture set to en-US. The result of the parsing would be 1000125 – the whole number without decimals. But if the current culture was da-DK the result would be the expected one with three decimals....

Read article

 
  Rename a file in C# properly

A while back I wrote a C# class that did fairly quick and easy encryption using the Rijndael method. It has two static functions that take a few parameters for the file to encrypt and at the end, I rename the newly created encrypted file to the name of the original file. The problem with this though is that the way I do it renames the file by first calling File.Replace() and then calling File.Delete() which deletes the temporary file that’s being created. On a large file, this can take a really long time to do. If this needs to happen to 30 files, it’s going to be very noticeable that there is a delay every time this needs to happen.

The solution is the use FileInfo.MoveTo() function which is much faster than File.Replace(). Make sure that the file name doesn’t already exist in the directory though.

 
  Data Tier Generator new version 4.2
Lately I’ve been using Data Tier Generator a lot for a new web application that I’ve been building that I’ll probably be releasing in the next few days but it had some problems handling ASP.NET membership database schema’s as well as GUID support issues. I got in touch with Adrian Anttila who wrote it and he was able to fix all of the issues that I’d found very quickly and so I’d like to bring attention to the new version of Data Tier Generator that Adrian has posted on SourceForge. The new version is version 4.2.

Thanks Adrian.
 
Wednesday, January 17, 2007
  Microsoft AJAX ATLAS intellisense for html doesn’t work

The other day I was having a problem while building aspx pages in Visual Studio using Microsoft AJAX control toolkit where even though I had setup the web.config file properly and the page worked in the browser, when I was in the editor, I would get red squiggly marks indicating that the tags I was using were invalid whenever I used an Microsoft AJAX ATLAS component.

The problem for me was that every page that uses any MS AJAX features must have a ScriptManager control on the page. So in order to avoid having to put a ScriptManager manually on each page, I declared it once on the master page. This allows the page with the MS AJAX control on it to render the control using the ScriptManager from the master page.

But in the Visual Studio editor, when I would close the Master page file, suddenly every page with an AJAX control would break. At first their working and not working seemed completely random because I didn’t realize that it had anything to do with the master page but then I realized that for some reason when the file was closed, it was no longer in memory and as such, the aspx page that I was working on that relied on the master page didn’t know that the master page had the declaration on it for the ScriptManager. That’s my theory on why it breaks at least.

So the solution for now is to just keep the Master page open while you’re working on pages that rely on it that have AJAX controls on them. Microsoft is supposed to be releasing a patch soon to fix this though in SP1.
 
Tuesday, January 16, 2007
  File Phantom on Bits Du Jour

There are a lot of sites online that have 24 hour, highly discounted sales of only a select amount of products that are often overstocked at other stores but there are very few successful software type sites that do the same thing but Bits Du Jour is one of the successful ones as it manages to attract a unique collection of software that it offers at a huge discount mainly from independent software developers.

My own software that I’ve been writing and selling online called File Phantom will be one of the featured products on Bits Du Jour on Monday, January 22nd. It will be selling for only 40% of the normal price which equates to $15.98. I also offer a 30 day free trial of the software at the File Phantom website so I suggest that you check out the software if you’re thinking of purchasing it on Monday. Normally File Phantom’s price is $39.95 so I think this is a really good deal.

I’m continuing development on the next version of File Phantom that has improved folder support, hotkey hiding and a whole new set of features but anyone that owns the current version will receive the new version for free. I’m hoping to release the next version around late February but it could be sooner.

I will try to report on how the sale on Bits Du Jour went when it completes as well.

 
Tuesday, January 09, 2007
  CSS in IE breaks with the xmlns tag that's used be default with aspx pages
I generally let all the HTML code be generated for me when I create an aspx page. Since I'm using Master Pages with ASP.NET 2.0, I really only ever create the HTML stuff once. All the head, body and ending stuff so I don't mess with it much but apparently having the tag

<html xmlns="http://www.w3.org/1999/xhtml">

breaks CSS in Internet Explorer (IE). It makes IE go into a weird display mode. Anyways, took me way too long to figure that out.
 
  CSS in Firefox and IE is crazy
I continue to be amazed at just how differently Firefox and IE work and how much better things work and look in Firefox 90% of the time. If I think "This makes sense" for code, most of the time it will work just like I expected in Firefox but probably not in IE. Anyways, here is a comparison of a webpage I've been working on in Firefox and IE. I'll be happy when I can get back to C# again.


 
Monday, January 08, 2007
  New look to my blog
I just created a new look for my blog this weekend. Let me know what you think of it.
 
Friday, January 05, 2007
  Generate C# code to consume your web service easily

WSDL stands for Web Services Description Language that is an XML language for describing web services. Although you could technically read it by eye and figure out what it’s trying to tell you, it’s not worth the effort. These documents are meant to be read by programs and figured out.

But you’re probably wondering, “Do I have a WSDL?” Actually, you do and you probably didn’t even realize it. For every web service that ASP.NET creates, it also generates the WSDL for you as well. Actually, it’s generated on the fly but that doesn’t really matter to you the programmer as long as it’s there when you need it. If you want to view the WSDL for a web service, type in the address to the web service and then follow that with “?WSDL” which will call the WSDL document. Below is an example of what this looks like.



Using this WSDL document, we’ll use a program that will generate C# code that will allow us to programmatically call C# objects in order to interact with the web services. After that, we’ll compile it into a DLL for our consumption.

First we need to locate the program called WSDL.exe which is a command line executable file from Microsoft. It typically comes with .NET but you can also download it from here.

http://www.epcc.ed.ac.uk/~ogsanet/wsdl/wsdl.exe

So I saved my WSDL file into the folder C:\webservices

I then opened up the command prompt in Windows and I typed in “wsdl http://localhost/Webservices/WebService.asmx?WSDL” and then hit enter.



Now notice the C# file that was created. This file contains all of the code we need to access the web service using only C# by just calling a single object.



It is a C# source code file with all of the code necessary to only have to call the function that is the web service. It’s going to be a global namespace though because we didn’t specify what the namespace should be for the C# file that was generated so in order to specify the namespace, the wsdl command line should look like this.

“wsdl /n:LinewaveWebServices http://localhost/Webservices/Service.asmx?WSDL”

So the namespace for the new C# web service access object is LinewaveWebServices.

Lets also compile this into a DLL while we’re at it. In order to do that, we need to call the .NET compiler. Depending on your version of .NET that you have installed, this isn’t going to be the same path probably but for me, the command looks like this.

cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

csc /t:library /out:C:\webservices\Services.dll C:\webservices\Service.cs

We need to make sure we’re in the directory that has the csc.exe program and once there, we can compile the C# code file and the /out: parameter determines where the output DLL will go which in this case is the origin of the C# file.

I’ve created a bat file to do all of this for me though so that anytime I make an update to my web service, the bat file only needs to be called and it generates my code files and compiles them. So my bat file looks like this.

cd C:\webservices

wsdl /n:LinewaveWebServices http://localhost/Webservices/Service.asmx?WSDL

cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

csc /t:library /out:C:\webservices\Services.dll C:\webservices\Service.cs

Now all that’s left for us to do is to drop that new DLL into our web project as a reference and start using the objects it created. You won’t have to worry about SOAP, XML or any of those things if you’re generating all of the code for your web service this way. All you need to do is just program into the objects like you would any other C# object but the only difference being these are hitting remote locations.

Pretty simple, huh?

 
  Return multiple values from a web service

At some point you’re going to find it useful to return a few different values at a time. The best way to do this is to actually create an object that will contain all the values that you will need to return and then pass that back as the return value.



For example, in the screenshot above, I’ve created a small class that initializes it’s public variables and then returns that newly created object. Once we look at the resultant XML, it will be clear what happened.

Picture

And then when we test the web service, the following XML is returned. Notice that the XML node names correspond to the names of the variables in the object that was returned.

But next, we’re going to look at how to actually use all of this XML data. Please, please, please don’t just create XML parsers. You need to be code generating and Microsoft has made generating code for web services incredibly easy if you’re using one of their .NET technologies. If you’re not, I have no idea what you do then but let’s assume we’re not in that predicament.

 
  Web services with parameters

That HelloWorld example was good and all but it didn’t have any parameters. All that we need to do in order to add a parameter to our web service is add a parameter to the HelloWorld function. I’ve also changed it to return that same parameter as the response.




Now go and view the web service like we did before. You’ll notice that on the page with the “Invoke” button, it now also has a textbox for the string. You can type in your name into this textbox and when the “Invoke” is clicked, it will return the name like my code shows it should do.

With the parameters for a web service, you can add as many parameters as you need like you would any other function. If your parameters are primitives (ie. String, int…), you can use the test tools for the web service but if the parameters are your own custom objects or even objects like DateTime, the test tools won’t work. If you need to pass a DateTime object though, don’t convert it into a String just so that you can test it. It’s better to just pass the DateTime object.

Here is an example of what it would look like with just a string as the parameter like we've setup above.



 
Thursday, January 04, 2007
  Testing web services made simple

With what we have now, this web service will actually work. You could right click the asmx file and click the “View in Browser” option and you’d get an interesting looking page with links that describe what the web service does and any functions it offers.

By default when we created the web service, the web service has a HelloWorld function that doesn’t take any parameters and just returns a string. This function is a useful way to check to make sure that you’re web service is actually working so you can view this in the browser and just make sure that it works. When the browser opens with the definition page of your web service, HelloWorld will be the first link on the page. Click the link. This will then give another page with a ton of XML and SOAP statements but near the top of the page, there should also be an “Invoke” button. The “Invoke” button will only appear if the web service is running locally. If you’re running this web service on a remote server, you won’t see the invoke button for security reasons because it probably wouldn’t be a good idea to expose this functionality to the outside world.

On the page with the invoke button, clicking the “Invoke” button will actually call the HelloWorld web service that you created and it will then return the result of it. If you have a simple web service that you’ve created, this is a great way to test it.

If you’ve added parameters to your web service that are primitives (ex. String, int…), you will be prompted to enter those in as well but since we’re using the default HelloWorld that doesn’t have any parameters, we don’t need to worry about those.






The result of the web service will be an XML return statement. You’ll notice that the return string is encapsulated in an XML node. The result of a web service is always XML but the hard part about web services is handling all the different XML return statements that can be generated. We’ll deal with that when we let a very cool tool generate all the code we’ll need for interfacing with the web services.

 
  Create a SOAP web service in less than 1 minute!
For the purposes of this, we’ll be creating our web service with Visual Studio 2005 in C# using ASP.NET. ASP.NET provides some great functionality that allows easy creation of web services with very very little fuss around the details of how they actually work. To create a web service in ASP.NET, you don’t need to know any SOAP or XML or any of those details. If you do, that’s great but not nessecary. Later on you might understand how some of the finer details work but they’re not necessary for getting the basics of the web service going.

First thing to do is in Visual Studio, you’ll need to actually create a web service file. With ASP.NET, these are of the file type asmx. You could create a blank file and rename it with the asmx extension but you’ll need to add some additional text to the file for the web service to work and so the simplest way to get your web service working quickly is to right click the project you have opened in Visual Studio and click the “Add New Item” option.


A selection box will appear. Select the “Web Service” item and name your web service that you’re creating.

It may be useful to know that the web service file you created can actually contain multiple functions so all of the services that you’ll provide could actually go under inside of one asmx file. You’ll see how that works shortly.

Now that we’ve added an asmx web services file, you’ll notice that by default Visual Studio opens the code behind file. Also note the location of this code behind file. It was place in the App_Code folder but the asmx file itself was placed wherever you originally created the file. The code behind file that you’re probably looking at right now ends with a .cs. You will actually build all of the web services from the .cs file and not from the .asmx file.

The asmx file and cs file are your new web service file that you’ve just created. You can right click on the file and click the “View in Browser” and you’ll see a page appear in your browser showing the web service definition page where all of the functions inside of your new web service will be listed out. This web service definition page is useful when viewing information on your web service while developing and for testing which we will cover next.




 
  Easily build and consume web services in C# and ASP.NET

This will be a series of posts beginning with this one on how to quickly build and consume web services in C# and ASP.NET. If you’ve been reading online much over the last few years on technology, there has been a lot of talk about web services and the technologies can be quite confusing but after doing a lot of work in them, I’m going to present the simplest, fastest ways that I’ve come up with for building, testing and consuming web services that you will probably ever see. It’s easy to get lost in all of the complexities of web services but they really aren’t that bad and 99% of the hard stuff you shouldn’t ever need to look at anyways. It always seems that websites are always trying to show you the hard stuff though.

Why am I writing this?

Web services, SOAP, XML, HTTP requests and everything else you need to build and consume a web service at face value seem a little bit complex. Actually, when I first looked at programming for web services a couple years ago, it was quite intimidating. But recently I’ve had to pick up using web services again for a web application that I’ve been building with a large number of web services that need to be exposed and as a result, I’ve had to look further at how to quickly use the web services both in generating them and consuming them.

This is the simplest, fastest way that I’ve come up with for creating web services, generating code for my web services and consuming web services. This is a series of posts that will be broken into a few different parts but should be a good primer on how web services work.

Here are the topics I plan to cover with my posts.

 
I am currently an ASP.NET, C# developer working on MangosteenNation.com, a XanGo website for helping people build their businesses. I am also pursuing a degree at CSU San Marcos in Southern California.

XanGo at Mangosteen Nation

Archives
October 2005 / November 2005 / December 2005 / January 2006 / February 2006 / March 2006 / April 2006 / May 2006 / June 2006 / July 2006 / August 2006 / September 2006 / October 2006 / November 2006 / December 2006 / January 2007 / April 2007 / May 2007 / June 2007 / August 2007 / February 2008 / August 2008 /


Powered by Blogger

Subscribe to
Posts [Atom]