Can access WSDL but not function using localhost RRS feed

All replies

  • User475983607 posted

    Jesse Herrera

    Does not Work: http://localhost/AppDLL/AppLogin.svc/GetEmployee/as_id=123123

    The URL is incorrect.  It's not possible to provide a solution as you have not provided enough information to guess the intent. 

    Usually with WCF you create a service reference and interact with the service like any local library.  If you created a WCF REST service then we need to see the URL template on the service interface.

    If you are new to WCF, the you'll want to go through a few Getting Started tutorials.


    If you are trying to build a REST service then I recommend going with Web API not WCF.


    Thursday, October 17, 2019 5:26 PM
  • User1022845535 posted

    Hiya, thanks for the response! I'll check out using a Web API but I would really like to figure out my problem before changing everything. I know the URLs don't work. They were more for illustrative purposes to show what is working and what is not working. Basically, the WCF code I've written is working great when I use the computer name to access the service. The problem is when I try to access it using "localhost" or "". I'm not sure why that isn't working. I'll keep digging but I appreciate your input.

    Thursday, October 17, 2019 6:12 PM
  • User475983607 posted

    Jesse Herrera

    The problem is when I try to access it using "localhost" or "". I'm not sure why that isn't working.

    This does not seem like a problem that needs fixing.  Localhost and (loopback) are used for development on local IIS instance.  You'll never use these localhost or once the app is moved to Dev, Test or Prod environments.  You'll move the application to its own application and domain rather than under the default app like you have now; OMPNAME123/AppDLL and localhost/AppDLL.

    I expect these URLs to cause a 404 since the URL is invalid.  I'm surprised the first URL is not causing a 404 too.


    I expect a query string like the following.


    I tried to reproduce the behavior but I'm not able to.  The following operational contract implementation requires a query string like above. 

            [Description("Description for GET /GetData")]
            public string GetData(int value)
                return string.Format("You entered: {0}", value);


    <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">You entered: 1</string>

    Thursday, October 17, 2019 7:35 PM
  • User1022845535 posted

    Talking through the problem pointed me in the right direction. The problem was I was compiling my application using a version of .NET that wasn't working on the server. Now everything is working when I access it on the server but I have a new issue that is unrelated to WCF I have to work through. My application is hosted on GoDaddy accessing WCF on another server so I am getting "from origin has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status." Back to Google to search for something to help. Thank you for your responses and helping to point me in the right direction.

    Thursday, October 17, 2019 8:19 PM
  • User475983607 posted

    Cross-origin resource sharing (CORS) is a browser security measure.   


    Basically, the server must pass headers to the browser that tells the browser it's okay to allow a Cross-origin requests.  As recommended, you're far better off implementing Web API as CORS is pretty simple to configure.  In WCF you'll need to write a bit of code to handle "OPTIONS".

    Thursday, October 17, 2019 8:28 PM
  • User-330142929 posted

    Given that you have solved the previous issue, I just give my advice on how to resolve the CORS issue in WCF.
    As you know, there is a security policy in the browser during access to the service by using the Javascript language, it allows the browser sending a cross-domain resource request, which enables AJAX could request the other websites service. Under this circumstance, by using CORS policy, we are capable of allowing the service is accessed with a particular host.
    This configuration is often completed by IIS (the Web server), however, it is also could be handled in WCF itself.
    Such as the WCF service application project template, we simply add the global.asax.cs file to the project and modify the below code.

    protected void Application_BeginRequest(object sender, EventArgs e)
    HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
    if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
    HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache");
    HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
    HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With,Accept");
    HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");

    The particular hostname could be added to the “Access-Control-Allow-Origin” field so that it could access the service without any CORS issue. By default, “*” means allow any host could access the service.
    Feel free to let me know if there is anything I can help with.

    Best Regards


    Friday, October 18, 2019 3:18 AM