I'm developing the simplest RESTful WCF service in a Worker Role which when deployed to production works perfectly well when using the physical IP address within the Azure VM, but when I use
the fully qualified service URL (even within the VM) I get a 405 Method Not Allowed error, inspecting with fiddler the RAW response specified only a POST operation is allowed.
Let me try and get the traces above to see what are in them...
So it turns out to be a pure WCF issue. This behavior is normal as you're using WebGet attribute for the OperationContract. This means the operation only accepts GET requests. For POST, etc. we need to use WebInvoke attribute. I have a sample
about RESTful WCF service that can help you quickly get started. Please check out below sample.
// NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
// NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in Web.config.
public class Service1 : IService1
public Message GetData()
WebOperationContext woc = WebOperationContext.Current;
woc.OutgoingResponse.Headers["Content-Type"] = "text/xml";
if (woc.IncomingRequest.UriTemplateMatch.QueryParameters.Count > 0)
querystring = woc.IncomingRequest.UriTemplateMatch.QueryParameters;
Client test code.
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
//buffer contains the data send to REST service
string s = "<test>Hello World!</test>";
//Important thing here. If it's not added we'll get 415
//The Content-Type header is essential when using RESTful
//services in general, but is especially important when
//making requests to RESTful services.
//If you don't have a Content-Type header in your HTTP
//request to a WCF service, you'll always get a
//"415 Missing Content Type" status code.
//You don't need the Content-Type header when making
//a GET request, since there isn't any entity body when
//making a GET request.
using (Stream postStream = hwr.GetRequestStream())
postStream.Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)hwr.GetResponse();
using (Stream respStream = response.GetResponseStream())
using (StreamReader streamRead = new StreamReader(respStream))
//render the result retrieved from REST service
A similar situation is faced when you have a silverlight enabled webrole. The ServiceReference.ClientConfig file has a similar link which denoted the ip address and port number appended with the Service1.svc url parameter. It denotes like this