Learn How to Find GPS Location on Any SmartPhone, and Then Make it Relevant


A step by step tutorial for getting GPS from any SmartPhone, even without GPS built in, and then making location useful.

Via CodeProject: Learn How to Find GPS Location on Any SmartPhone, and Then Make it Relevant. Free source code and programming help


Simulating Email in .NET


The trick to doing this is not to hardcode things like host, port, etc. for your SMTP server when you use System.Net.Mail to send mail. Instead, use the default ctor for SmtpClient.

What you’re telling .NET by using the default ctor for SmtpClient is, "please use my config file to figure out how to send mail". Now you can use the system.net/mailSettings/smtp section in config to specify the details of your mail server.

During development, I use different settings because I don’t usually want to deal with the hassle of installing an SMTP server on my development box. Instead, I want email messages delivered as individual files in a directory on my hard drive (I always have a c:\mail directory on my development box for just this purpose):

<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="c:\mail"/>

Via Simulating Email in .NET

What’s inside the WCF REST Starter Kit

  • Visual Studio Project Templates image
    • REST Singleton Service produces a service that exposes the full HTTP interface (GET, POST, PUT, and DELETE) around a singleton resource, and it automatically provides both XML and JSON representations for the underlying resource.
    • REST Collection Service similar to the REST Singleton Service only it also provides support for managing a collection of SampleItem resources.
    • HTTP Plain XML Service provides ONLY the GET and POST operations for those who don’t care about fully conforming to the RESTful design  and would rather build a REST/RPC hybrid service by overloading GET and POST using the HTTP Headers.
    • Atom Feed Service template provides a sample implementation that shows how to programmatically generate and return a SyndicationFeed instance.
    • Atom Publishing Protocol Service template produces a full-fledged AtomPub service capable of managing collections of resources as well as media entries.
  • WebProtocolException allows you to directly set your HTTP status code.
  • WebServiceHost2/WebServiceHost2Factory which provides a zero-config experience. Provide support for Help Page.
  • Help Page and using [WebHelp] for annotation. Simply navigate to /help image
  • [WebCache]
  • RequestInterceptor
  • Added Extension methods to the WebOperationContext class.

You can download the WCF REST Starter Kit here.

For samples of using the starter kit, look at this A Developer Guide to the WCF REST Starter Kit.

A Tutorial on Building RESTful Web Services with WCF 3.5


  • [WebGet], [WebInvoke] to define mappings for the Http Methods Interface
  • UriTemplate to map objects to method signatures through WebGet/WebInvoke Attributes image image
  • WebOperationContext to access the HTTP Request/Response including header and status code
  • <%@ ServiceHost Factory=”WebServiceHostFactory” to auto-config the Web endpoints binding and behavior without edit web.config.
  • aspNetCompatibilityEnabled(web.config) & AspNetCompatibilityRequirements(.cs) to access HttpContext
  • (optional) using Microsoft URL Rewrite Module for IIS 7.0 to remove the .svc from the URIs.
  • RequestFormat/ResponseFormat=WebMessageFormat.Xml/WebMessageFormat.Json through WebGet/WebInvoke Attributes.image
  • WebScriptServiceHost to auto-generate a Ajax-friendly JSON javascript proxy for web browsers. Append /js to the end of base address to get to the proxy.
  • Use SyndicationFeed, SyndicationItem, SyndicationContent to build generic logical feeds.
  • Use Atom10FeedFormatter, RSS20FeedFormatterClass to turn a SyndicationFeed object to Atom/RSS specific feed format. Method can use SyndicationFeedFormatter base class to return various formatter object.  
  • Use ServiceDocument, ServiceDocumentFormatter, AtomPub10ServiceDocumentFormatter, and Workspace to generate AtomPub service document. note: AtomPub as a standard application of the HTTP uniform interface(GET/PUT/POST/DELETE) but applied specifically to Atom feeds, which are modeled as collections of entries.
  • Too tedious, try WCF REST Starter Kit. and you can download here.

Via A Guide to Designing and Building RESTful Web Services with WCF 3.5

PUT vs POST in RESTful Web Service

Let us use a bookmark service as an example.



We can use PUT to create new user accounts because the client is the one picking the username that forms the new resource’s URI. If the client is successful, the service will return a 201 (“Created”) response. If the client attempts to use an existing username, the service will return a 401 (“Unauthorized”) response. When issuing the PUT request to create a user account, the client will provide a user account representation in the HTTP request body containing the user’s information.

For individual bookmark resources, we’ll support GET, POST, PUT, and DELETE requests. If a particular bookmark is marked as private, only the owner can retrieve it, but if it’s public, anyone can retrieve it. When a user creates a new bookmark, the service is responsible for assigning it a unique bookmark Id. Hence, the client won’t know the Id to use in the URI ahead of time. So, instead of using a PUT request, we’ll have users POST bookmarks to the user’s bookmark collection resource.  The handler for the POST request will create the new bookmark, assign it an Id, and return a 201 (“Created”) to the client, specifying the URI of the new bookmark resource in the Location header.

This explains when to use POST or PUT for creating new resources. The answer ultimately lies in who is responsible for determining the new resource’s URI. If the client is in charge, the client can use PUT to the new URI (like we did for user accounts) and the service can return a response code of 201 (“Created”). However, if the service is in charge of generating the new URI, the client should POST the new resource to a factory URI like we’ve done for bookmarks. Then, the service can return a response code of 201 (“Created”) along with the URI of the new resource in the response “Location” header.

Once clients know the bookmark ID’s, they can issue PUT and DELETE requests to individual bookmark URIs to update and delete bookmarks.

A Brief Introduction to REST




Key REST principles

Most introductions to REST start with the formal definition and background. I’ll defer this for a while and provide a simplified, pragmatic definition: REST is a set of principles that define how Web standards, such as HTTP and URIs, are supposed to be used (which often differs quite a bit from what many people actually do). The promise is that if you adhere to REST principles while designing your application, you will end up with a system that exploits the Web’s architecture to your benefit. In summary, the five key principles are:

  • Give every “thing” an ID
  • Link things together
  • Use standard methods
  • Resources with multiple representations
  • Communicate statelessly

Let’s take a closer look at each of these principles.

Via InfoQ: A Brief Introduction to REST