【问题标题】:Asp.Net wcf service endpointAsp.Net wcf 服务端点
【发布时间】:2013-11-16 19:26:00
【问题描述】:

我在一个 asp.net 服务项目中有一组服务。我已经在 web.config 中为它们配置了端点。

这就是我在 web.config 中设置端点的方式:

<bindings>
  <basicHttpBinding>
    <binding name="GeneralBindingConfig" maxBufferSize="524288" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600">
      <readerQuotas maxDepth="32" maxStringContentLength="100000" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="None" />
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service name="TeamTravel.Cloud.Services.ServiceContracts.AccountServices">
    <endpoint address="/Services" binding="basicHttpBinding" bindingConfiguration="GeneralBindingConfig" contract="TeamTravel.Cloud.Services.ServiceContracts.Interfaces.IAccountServices" />
  </service>
  <service name="TeamTravel.Cloud.Services.ServiceContracts.JourneyServices">
    <endpoint address="/Services" binding="basicHttpBinding" bindingConfiguration="GeneralBindingConfig" contract="TeamTravel.Cloud.Services.ServiceContracts.Interfaces.IJourneyServices" />
  </service>
  <service name="TeamTravel.Cloud.Services.ServiceContracts.JourneyTrackerServices">
    <endpoint address="/Services" binding="basicHttpBinding" bindingConfiguration="GeneralBindingConfig" contract="TeamTravel.Cloud.Services.ServiceContracts.Interfaces.IJourneyTrackerServices" />
  </service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

在 IIS 中,我在此绑定下安装了网站:www.teamtravel.com 我还在我的 hosts 文件中添加了该条目,以便我可以从该 url 在本地访问该网站。

所以根据配置,我应该能够访问这样的服务:

www.teamtravel.com/Services/AccountServices.svc

AccountServices.svc 是 asp.net wcf 服务。

但我被重定向到错误路径:

http://teamtravel.com/default.aspx?aspxerrorpath=/Services/AccountServices.svc

【问题讨论】:

  • 我从未听说过“ASP.NET WCF 服务”。这两种技术非常不同。用于创建项目的实际 Visual Studio 模板是什么?

标签: asp.net wcf


【解决方案1】:

在 IIS 上托管 WCF 服务时,服务所在的虚拟目录定义了服务端点的地址,因此您可以将此属性留空:

<endpoint address="" ... />

您的服务可以从www.teamtravel.com/&lt;YourIISVirtualDirectory&gt;/AccountServices.svc 联系到。

Address 属性可用于添加地址相对于该地址的端点:

<endpoint address="anotherEndpoint" .../>

所以这个端点可以从www.teamtravel.com/&lt;YourIISVirtualDirectory&gt;/AccountServices.svc/anotherEndpoint访问

作为参考,请阅读 MSDN 中的Deploying an Internet Information Services-Hosted WCF Service

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-13
    • 2015-08-20
    • 1970-01-01
    • 2014-05-18
    • 2010-09-16
    • 2012-08-28
    • 2014-05-04
    • 2012-06-30
    相关资源
    最近更新 更多