【发布时间】:2014-09-11 08:47:35
【问题描述】:
我一直在寻找几个小时,但我找不到解决方案。我简单解释一下。
我正在学习 WCF 服务。我刚刚创建了一个服务并浏览它。这是配置文件:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="EmployeeServiceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="EmployeeServiceBehaviour" name="EmployeeConfiguration">
<endpoint address="http://localhost:2005/EmployeeService.svc" binding="basicHttpBinding"
bindingConfiguration="" contract="IEmployeeConfiguration" />
</service>
</services>
</system.serviceModel>
<system.web>
<compilation debug="true"/>
</system.web>
<system.webServer>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
从 Visual Studio 浏览时似乎没有问题。效果很好。
其次,我正在尝试在 IIS 上发布它。我正在做的是这样的:
我将服务发布到一个文件夹并将该服务添加到 IIS。
我选择了 3006 端口作为端口。
在其配置文件下方。请注意,我还将配置中的端口更改为 3006
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="EmployeeServiceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="EmployeeServiceBehaviour" name="EmployeeConfiguration">
<endpoint address="http://localhost:3006/EmployeeService.svc" binding="basicHttpBinding"
bindingConfiguration="" contract="IEmployeeConfiguration" />
</service>
</services>
</system.serviceModel>
<system.web>
<compilation/>
</system.web>
<system.webServer>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
我正在等待顺利运行,但是:
IIS 给我一个来自 Chrome 的空白页
以及来自资源管理器的 HTTP 400 错误请求
最后,如果我从配置文件中删除地址部分,一切正常。但其他令人困惑的事情是,在上述场景(提供地址)之后,在我的另一台计算机上,我可以访问该服务。所以,我真的厌倦了寻找为什么这在一台计算机上工作而不在另一台计算机上工作。谁能给我解释一下?
我知道它有点长,但我必须解释清楚。 谢谢
【问题讨论】:
-
我遇到了同样的问题,我解决了。那是很久以前的事了,但如果到那时还没有人回答你,我可以找到文档:)
-
@Alireza 谢谢。我会很感激你,如果你现在为我提供。因为我在任何地方都找不到答案,而且你很可能很快就会忘记这个问题:)
-
不,我不会。不要让我保持清醒去寻找解决方案 ;-) 这里是凌晨 2 点,我困了
-
@Alireza 好的。现在睡觉:) 如果没有人回答,我等着你的消息
-
梅尔哈巴!我认为这不仅仅是一项服务。您能否添加一个简单的 ASPX 页面并将其发布到这个新网站,然后看看您是否可以浏览该页面?