none
WCF .net 3.5 multiple errors: virtual path error, not authorized to view this page RRS feed

  • Question

  •  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;
        }
        }
        }


    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.

    Also 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 

    I have two questions:

    1) why I am getting virtual path error and also cannot browse to my svc file in virtual directory? 2) Also How can I direct the service to a url like: localhost:8080, so I can use access url localhost:8080/service/* to get the config results, how to customize the access service url?

    Can someone please tell me how to fix my problems?

    Monday, March 18, 2013 5:59 AM

Answers

All replies