none
WCF Service giving 404 error externally but works fine internally RRS feed

  • Question

  • My company is trying WCF REST service. It works fine in my localhost under IIS. I then deployed the service to an internal server under IIS and the service works fine in our local internal network, but when trying to access externally is throwing 404 "Server Error in '/' Application". There is a DMZ with a firewall in between the internal server and the public traffic. The internal server has several sites that are working well but none are WCF. I then added a simple html page called "Intents" to the wcf service to see if the routes are working and it is accessible externally. All that I can see externally is the directory. Once I click "drillservice.svc" is giving 404. Below is my config file. I have spent 4 days and I am pretty new to wcf services. Thanks in advance for any help.
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.net>
        <defaultProxy useDefaultCredentials="true">
          <proxy usesystemdefault="True" />
        </defaultProxy>
      </system.net>
     
      <system.diagnostics>
        <sources>
          <source propagateActivity="true" name="System.ServiceModel" switchValue="Warning.ActivityTracing">
            <listeners>
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              </add>
              <add name="ServiceModelTraceListener">
                <filter type="" />
              </add>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
          <add initializeData="S:\WCFRestService\WCFDrillSvc\web_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
            <filter type="" />
          </add>
        </sharedListeners>
      </system.diagnostics>
      <appSettings />
      <connectionStrings>
        <add name="cn" connectionString="Data Source =mssqlserver ;  initial catalog=Drillers; User Id=userid; Password=passkey" providerName="System.Data.SqlClient" />
      </connectionStrings>
      <system.web>
        
        <compilation debug="true" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
          </assemblies>
        </compilation>
        
        <authentication mode="Windows" />
       
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
            <identity impersonate="false" />
      </system.web>
      <!-- 
          The system.webServer section is required for running ASP.NET AJAX under Internet
          Information Services 7.0.  It is not necessary for previous version of IIS.
      -->
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
          <remove name="webDAVModule" />
        </modules>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true" />
      </system.webServer>
      <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true">
        </serviceHostingEnvironment>
        <services>
          <service behaviorConfiguration="DrillServiceBehavior" name="DrillService">
            <endpoint address="" behaviorConfiguration="WCFDrillWebBehavior" binding="webHttpBinding" name="DrillServiceEndpoint"
                      contract="IDrillService">
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" name="DrillServiceEndpoint2" contract="IMetadataExchange" />
          </service>
        </services>
        <behaviors>
          <endpointBehaviors>
            <behavior name="WCFDrillWebBehavior">
              
            </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
              
            </behavior>
            <behavior name="DrillServiceBehavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>



    • Edited by Georgie7 Friday, October 9, 2015 8:35 PM
    Friday, October 9, 2015 7:28 PM

Answers

  • Finally after doing all kind of changes I found the problem. In the hosted internal server of the wcf service under inetpub/wwwroot there is a config file specifically for the IIS site not the service web.config. After adding this code it worked the first try. The DMZ needed no changes. At first I inserted this code to the service web.config and problem got worse. But it actually goes in the site config file. Hope this will help others.
    <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
    </system.serviceModel>

    • Marked as answer by Georgie7 Tuesday, October 13, 2015 5:22 PM
    Tuesday, October 13, 2015 5:22 PM

All replies

  • http://www.asjava.com/tools/fiddler-tutorial-how-to-use-fiddler/

    It really has nothing to do with WCF per say. It has to do with why the client can't find the service by its URL.  

    The 404 means the client with the URL that it is using cannot find the service. You need to use Fiddler and inspect the URL from a client on the Intranet and Internet perspective when the 404 is thrown, which you can do with Fiddler.

    I would suspect that there is some kind of firewall issue that is blocking the initial inbound traffic contact  with the service from the client, which must happen before communications will commence between the client and the service. 

    You should be able to see the FW blocking the traffic in the FW logs, if the FW is the issue.

    • Proposed as answer by jwbutler123 Wednesday, August 1, 2018 9:18 PM
    Friday, October 9, 2015 9:32 PM
  • Finally after doing all kind of changes I found the problem. In the hosted internal server of the wcf service under inetpub/wwwroot there is a config file specifically for the IIS site not the service web.config. After adding this code it worked the first try. The DMZ needed no changes. At first I inserted this code to the service web.config and problem got worse. But it actually goes in the site config file. Hope this will help others.
    <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
    </system.serviceModel>

    • Marked as answer by Georgie7 Tuesday, October 13, 2015 5:22 PM
    Tuesday, October 13, 2015 5:22 PM
  • This was the fix for my situation.
    Wednesday, August 1, 2018 9:19 PM