[英]WCF service works internally but not externally
I have a WCF service on framework 4 works well inside the internal network. 我在框架4上有一个WCF服务,在内部网络中运行良好。 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".
在外部,我可以看到目录浏览,因为已在web.config中启用了目录浏览,但是一旦单击svc文件,就会抛出404“'/'应用程序中的服务器错误”。 There is also a DMZ reverse proxy and I am sure that is my problem.
还有一个DMZ反向代理,我敢肯定这是我的问题。 I checked the IIS-7 logs and the 404 error is not being logged only 200 OK from internal access are logged.
我检查了IIS-7日志,未记录404错误,仅记录了200次来自内部访问的OK。 The IIS has lots of services and sites running but this is the first time my company is trying WCF with REST service.
IIS运行着许多服务和站点,但这是我公司第一次尝试将WCF与REST服务一起使用。 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. 更新:我添加了一个简单的HTML页面,它可以从外部公众使用,但是svc文件仍然抛出404错误,但未找到。
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.
在inetpub / wwwroot下的wcf服务的托管内部服务器中,有一个专门用于IIS站点的配置文件,而不是服务web.config。 After adding this code it worked the first try.
添加此代码后,它可以进行第一次尝试。 The DMZ needed no changes.
DMZ无需更改。 Hope this will help others.
希望这对其他人有帮助。
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
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: 在不了解有关环境,代理或您如何测试服务的情况下很难确定地说,但是这里有几件事需要检查:
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: 最后,如果您尝试通过HTTPS从外部浏览服务,则需要确保在配置中通过HTTPS公开服务元数据:
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
Hope this helps point you in the right direction. 希望这可以帮助您指出正确的方向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.