Asp.Net wcf服务端点

时间:2013-11-16 19:26:00

标签: asp.net wcf

我在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 services。

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

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

1 个答案:

答案 0 :(得分:1)

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

<endpoint address="" ... />

您的服务可以从www.teamtravel.com/<YourIISVirtualDirectory>/AccountServices.svc开始。

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

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

因此可以从www.teamtravel.com/<YourIISVirtualDirectory>/AccountServices.svc/anotherEndpoint

访问此端点

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