2015-10-05 43 views
0

我在框架4上有一個WCF服務,在內部網絡中工作良好。外部我可以看到目錄瀏覽,因爲在web.config中啓用,但是一旦我點擊svc文件就會在'/'Application'中拋出404「服務器錯誤。還有一個DMZ反向代理,我相信這是我的問題。我檢查了IIS-7日誌,並且404錯誤沒有被記錄,只有200 OK從內部訪問被記錄。 IIS有很多服務和網站正在運行,但這是我公司第一次嘗試使用REST服務的WCF。幾天來,我一直在尋找答案,只找到不適合我的項目的解決方案。以下是我的配置文件。預先感謝您的幫助。WCF服務在內部工作,但不在外部

<?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>` 

更新:我添加了一個簡單的HTML頁面,並將其從外部公共工程,但SVC文件仍然拋出404未找到錯誤。

+0

您的意思是,當您單擊鏈接以查看幫助頁面上的WSDL時,它將引發404錯誤?你可以從外部訪問幫助頁面? –

+0

嗨,詹姆斯,當我點擊查看svc服務,並在那裏列出wsdl它會在外部拋出一個404。在內部,我可以打開它並使用該服務。 – Deleted

回答

1

最後,在做了所有類型的更改後,我發現了這個問題。在inetpub/wwwroot下的wcf服務的託管內部服務器中,存在專門用於IIS站點的配置文件,而不是服務web.config。添加此代碼後,它第一次嘗試。 DMZ不需要改變。希望這會幫助其他人。

<system.serviceModel> 
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/> 
</system.serviceModel> 
0

這很難肯定的說,無需瞭解環境,代理,或如何你正在測試的服務什麼,但這裏有幾件事情要檢查:

  • 驗證代理正確配置。
  • 驗證服務是否可以從代理服務器訪問。

最後,如果你想通過HTTPS瀏覽外部服務,你需要確保服務元數據被曝光通過HTTPS在您的配置:

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

希望這有助於指出你在正確的方向。

+0

我曾嘗試過這些設置,但沒有更改。我在想,我需要一個位於非軍事區的網絡應用程序來調用服務,但我認爲我的老闆不會那麼喜歡。除此之外,我會嘗試不同的服務,因爲我迷路了。它在內部完美無缺,但在外部投擲404。而所有其他Web表單,不是WCF的服務在內部和外部都可以正常工作。 – Deleted

相關問題