I have a simple WCF Rest Service with one method. The interface is defined as:
[ServiceContract]
public interface IHelloRest
{
[OperationContract]
[WebGet(UriTemplate = "json/hello/{name}", ResponseFormat = WebMessageFormat.Json)]
string Hello(string name);
}
The implementation is defined as:
public string Hello(string name)
{
return string.Format("Hello {0}. You called my Hello method", name);
}
I deployed this service to IIS 7 running on Windows Server 2008 and here are the steps I did to add the service:
- I started IIS Manager
- I Right-Clicked on Sites and Chose Add Web Site...
- I put 'Test' for Site Name
- For the application pool, I chose ASP.NE v4.0
- For the physical path, I put the root folder of my service.
- For Binding, I put http, I left IP address unassigned and I left the port at 80.
- I did not give a Host name
- I left Start Web Site immediately checked.
- I clicked Ok and then browsed to my site.
After doing the above steps, there are a few issues I run into:
When I browse to http://localhost/HelloRestService.svc/json/hello/xaisoft, it asks me if I want to download the file. If I download it and open it, it contains the response in json format. On my local machine, when I hosted this in IIS, it worked fine, but on this remote machine, it only asks me if I want to download the file.
The other issue is that I don't want the host to be localhost, I want something like demo.rest.com, so I would browse to http://demo.rest.com/json/hello/xaisoft, but if I change the host to demo.rest.com and try to browse the service now, it attempts to go to:
http://demo.rest.com/HelloRestService.svc, but says the Internet Explorer cannot display the webpage.