0

I have a WCF service on framework 4 works well inside the internal network. Externally I can see the directory browsing because is enabled in web.config but once I click the svc file is throwing 404 "Server Error in '/' Application". There is also a DMZ reverse proxy and I am sure that is my problem. I checked the IIS-7 logs and the 404 error is not being logged only 200 OK from internal access are logged. The IIS has lots of services and sites running but this is the first time my company is trying WCF with REST service. For days I been looking for answers only finding solutions that are not working on my project. Below is my config file. Thanks in advance for any help.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.net>
<defaultProxy useDefaultCredentials="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="X:\RestService\DrillSvc\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 =test ;  initial catalog=Drillers; User Id=userid; Password=password" 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=31BF3856AD364123" />
  </assemblies>
</compilation>
<authentication mode="Windows" />
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
    <identity impersonate="false" />
</system.web>

<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
  <!--<remove name="webDAVModule"/>-->
</modules>

<directoryBrowse enabled="true" />
</system.webServer>
<system.serviceModel>
<bindings>
  <webHttpBinding>
    <binding name="WCFwebBinding">
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="Windows"/>
      </security>
    </binding>  

  </webHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">    </serviceHostingEnvironment>
<services>
  <service behaviorConfiguration="DrillServiceBehavior" name="DrillService">
    <endpoint address="" behaviorConfiguration="WCFDrillWebBehavior" binding="webHttpBinding" contract="IDrillService">
      <identity>
        <dns value="mycompany.com" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="WCFDrillWebBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
    <behavior name="DrillServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>`

Update: I added a simple HTML page and it works from the external public but the svc file is still throwing 404 error not found.

Deleted
  • 91
  • 1
  • 13
  • Do you mean that when you click the link to view the WSDL on the help page it's throwing a 404 error? And you're able to access the help page externally? – James Johnson Oct 05 '15 at 18:54
  • Hi James, when I click to view the svc service and in there it list wsdl it throws a 404 externally. Internally I can open it fine and use the service. – Deleted Oct 05 '15 at 19:09

2 Answers2

1

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. Hope this will help others.

<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
Deleted
  • 91
  • 1
  • 13
0

It's difficult to say for sure without knowing anything about the environment, the proxy, or how you're testing the service, but here are a couple things to check out:

  • Verify that the proxy is configured correctly.
  • Verify that the service is accessible from the proxy server.

Lastly, if you're trying to browse the service externally over HTTPS, you would need to make sure that the service metadata is being exposed over HTTPS in your configuration:

<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />

Hope this helps point you in the right direction.

James Johnson
  • 45,496
  • 8
  • 73
  • 110
  • I have tried those settings before and no change. I am thinking that I will need a web app that sits in the DMZ that calls the service but I think my boss would not like that. Other than that I will try a different service because I am lost. It makes no sense works perfectly internally but throwing a 404 externally. And all the other web forms, services that are not WCF work fine internally and externally. – Deleted Oct 07 '15 at 16:30