This blog is simply explains the trick for getting the Server URL for SOAP Endpoint or REST Endpoint from the Context.
In CRM 2011
We were using following two lines of code to get Server URL.
var context = GetGlobalContext(); serverUrl = context.getServerUrl();
Now in CRM 2013
getClientUrl() will be supported instead of
var context = GetGlobalContext(); clientUrl = context.getClientUrl();