Required Reading for Creating and Deploying a WCF REST Service on IIS7

Deploying a REST service with Windows Communication Foundation (WCF) is great, because it’s very powerful, but it can also be enormously frustrating.

First of all, start by reading the whitepaper.
http://msdn.microsoft.com/en-us/library/dd203052.aspx

This will give you a great overview on how to construct your methods, and how to label them in order to have them exposed correctly by REST.

Next, you need to create your web.config file. Use webhttpbinding for REST.

Lastly, deployment:

How to use https for WCF services in IIS7

How to rewrite your URLs to get rid of the lame .svc extension

I am posting a small demo project, hopefully it’s useful to someone. Simply implement the API interface as you see fit, and the rest basically does itself. You’ll notice the web.config includes a SOAP binding for legacy Microsoft clients to use if they wish.

Link: API_Template

mysql command doesn’t work in OS X snow leopard

So you install mySql on your mac, and it’s working great, but then you go into terminal to run a mysqldump or something, and it doesn’t work!

you get a message something like:

-bash: mysqldump: command not found

so how do you fix this? well, copy and paste the following into your terminal window and press enter:

echo export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH" >> ~/.profile

source ~/.profile

whoa, whoa, you say. what is this doing? It makes it so that when you type any command into the terminal, it does a check of these folders before giving you the “command not found” error.

If you want to undo it, you can always edit your .profile, or just delete it.

VirtualHostX and mod_rewrite

To enable mod_rewrite manually, see: OS X server tips but if you are using VirtualHostX it changes your default config file. Add the following code to the Directives box:

Options FollowSymLinks
AllowOverride All AuthConfig
Order deny,allow
Deny from all

if you’re using the new version of VirtualHostX, make sure that you select Directory from the dropdown, then use:

Options FollowSymLinks
AllowOverride All AuthConfig

How to do multiple virtual hosts on OS X

  1. Download and install VirtualHostX (don’t forget to back up your existing config!!)
  2. Download and install Gas Mask (manages multiple hosts files, dumb name though)
  3. If you want to do this with WordPress and you have a database locally and another one on a dev server somewhere, you can do the following code:

if(eregi(“^mywebsitename.com$”, $_SERVER[HTTP_HOST]))

{

define(‘DB_NAME’, ‘dbremotename’);

/** MySQL database username */

define(‘DB_USER’, ‘dbremoteuser’);

/** MySQL database password */

define(‘DB_PASSWORD’, ‘dbremotepassword’);

/** MySQL hostname */

define(‘DB_HOST’, ‘dbremotehost’);

define(‘WP_SITEURL’, http://mywebsitename.com’);

define(‘WP_HOME’, http://mywebsitename.com’);

}

else{

define(‘DB_NAME’, ‘dbremotename’);

/** MySQL database username */

define(‘DB_USER’, ‘dblocaluser’);

/** MySQL database password */

define(‘DB_PASSWORD’, ‘dblocalpassword’);

/** MySQL hostname */

define(‘DB_HOST’, ‘dblocalhost’);

define(‘WP_SITEURL’, http://mywebsitename.com’);

define(‘WP_HOME’, http://mywebsitename.com’);

}