我有一个在WCFSvcHost中托管时可以正常工作的WCF服务;但是,当我将其作为Windows服务托管时,我收到以下错误:
未处理的类型' System.InvalidOperationException'发生在System.ServiceModel.dll中。附加信息:ServiceMetadataBehavior的HttpGetEnabled属性设置为true,HttpGetUrl属性是相对地址,但没有http基址。提供http基址或将HttpGetUrl设置为绝对地址。
以下是我的配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<services>
<service name="FileBetService.Service">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="LargeMessageBinding"
contract="FileBetService.IService"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/FB/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="LargeMessageBinding"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
closeTimeout="00:15:00"
openTimeout="00:15:00"
receiveTimeout="00:15:00"
sendTimeout="00:15:00">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
我已对我的应用配置进行了一些建议的更改,错误不再出现,但元数据(wsdl)未显示
<system.serviceModel>
<services>
<service name="FileBetService.Service">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/IService/"/>
</baseAddresses>
</host>
<endpoint address="mex" binding="mexHttpBinding" contrac="IMetadataExchange"></endpoint>
<endpoint address="http://localhost:8000/FBTurf12/" binding="basicHttpBinding" bindingConfiguration="LargeMessageBinding" contract="FileBetService.IService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="default">
<serviceMetadata httpGetEnabled="True" httpGetUrl="http://localhost:8000/IService/mex"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="LargeMessageBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="00:15:00" openTimeout="00:15:00" receiveTimeout="00:15:00" sendTimeout="00:15:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>