我已经搜索了几个小时,但是找不到解决方案。我将简要说明。
我正在学习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作为端口。
在其配置文件下方。请注意,我还将config中的端口更改为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错误请求
Lastly, if I remove address part from config file everything works well. But other confused thing is that, on my other computer after above scenario(address provided) I can reach the service. So, I really tired of searching why this is working on one computer and not working on another one. Could someone explain it to me?
I know it is a bit longer, but I have to explain it clearly. Thanks
According my searches I should not provide an address.
msdn.microsoft.com/en-us/library/aa751792(v=vs.110).aspx
您必须始终将相对端点地址用于IIS托管的服务端点。如果端点地址未指向承载暴露端点的服务的IIS应用程序,则提供标准端点地址(例如,localhost / MyService.svc)可能会导致服务部署错误。对托管服务使用相对端点地址可以避免这些潜在的冲突。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句