我通过创建WCFService应用程序项目类型在IIS7上托管了WCF服务。
在WCF服务解决方案中,有两个Project。 1)实际* WCFService * * 和2) WCFService应用程序 * 用于托管它在IIS7.0中
1)实际的WCFService项目。的的app.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="DHDocuments.DService">
<endpoint address="" binding="wsHttpBinding"
contract="DHDocuments.IDService" >
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/DHDocuments/DService/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
2)WCFService Application web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<services>
<service name="DHDocuments.DService">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration=""
name="basic"
contract="DHDocuments.IDService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
在IIS中托管它。它位于 http://localhost:2004/DService.svc
现在来到WCF消费项目,
我已通过指向 http://localhost:2004/DService.svc
添加了服务参考。在我的WCF Consuming客户端项目中,这是 app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<client>
<endpoint address="http://localhost:2004/DService.svc"
binding="basicHttpBinding"
bindingConfiguration="basic1"
contract="WCFDHService.IDService"
name="basic" />
</client>
<bindings>
<basicHttpBinding>
<binding name="basic1" closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName"
algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
system.serviceModel / bindings / basicHttpBinding处的绑定没有名为“basic1”的已配置绑定。这是bindingConfiguration
的无效值**
有人能指出错过的内容吗?
当我通过调试模式直接使用wcf服务而没有在IIS中托管它时没有问题。我确定,绑定配置会出错。
答案 0 :(得分:0)
您似乎已使用mex端点配置了用于元数据发现的服务:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
服务配置中的另一个端点定义为wsHttpBinding:
<endpoint address="" binding="wsHttpBinding" contract="DHDocuments.IDService" >
我猜测,因为mex已启用,客户端代理将生成wsdl,但是,如果使用传输安全性,则需要指定https。或者在wcf服务中添加 basicHttpBinding 的端点。
您似乎正在尝试使用basicHttpBinding配置在客户端代理中访问您的服务,但该服务未配置为接受或侦听此类服务。