I created a sample wcf REST service in .NET 3.5 vs.net 2008 Defined interface cdservice
[ServiceContract]
public interface CdService
{
[OperationContract]
[WebGet(UriTemplate = "service/*", ResponseFormat = WebMessageFormat.Xml)]
string[] GetConfig();
}
Implemented GetConfig in Service1.cs
namespace CdService
{
public class Service1 : CdService
{
public string[] GetConfig()
{
string[] services = new string[] { "Sales", "Marketing", "Finance" };
return services;
}
}
}
Set virtual directory and pointed it to my project
I go to my virtual directory and try to browse service1.svc file, I get error message: You are not authorized to view this page Can someone please tell me what is wrong?
add comment
When I run the program it opens up browser and says:
You have created a service. To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax: svcutil.exe http://localhost:1496/Service1.svc?wsdl
When I change the URL to http://localhost:1496/Service1.svc/service/ Gives following error: Server Error in '/' Application. '/Service1.svc/service/' is not a valid virtual path.
I have two questions: 1) Please can someone tell why I am getting virtual path error? 2) Also How can I direct the service to a different port of my choice localhost:8080, so I can use access url localhost:8080/service/* to get the config results?