我运行程序老是提示下面的错误用户代码未处理invalidOperationException
配置中找不到绑定类型 wsHttpBinding 实例 wsHttpBinding。下面是WCF web.config代码
<system.serviceModel>
<protocolMapping>
</protocolMapping>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehavior">
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="65536000"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!--添加服务-->
<services>
<!--name必须与代码中的host实例初始化服务一样
behaviorConfiguration配置行为-->
<service behaviorConfiguration="myServiceBehavior" name="WcfService1.Service1">
<!--添加契约接口contract="WcfService1.IService1"为契约接口 binding="wsHttpBinding" wsHttpBinding同为http调用 BasicHttpBinding-->
<endpoint address="" binding="wsHttpBinding" contract="WcfService1.IService1"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
<host>
<baseAddresses>
<!--添加调用服务地址-->
<add baseAddress="http://localhost:1682/"/>
<add baseAddress="http://localhost:1592/"/>
</baseAddresses>
</host>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>下面是ServiceReferences.ClientConfig代码
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="wsHttpBinding_IService1">
<binaryMessageEncoding/>
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="" binding="wsHttpBinding"
contract="WcfService1.IService1"
bindingConfiguration="myServiceBehavior"
name="myServiceBehavior" />
</client>
</system.serviceModel>
</configuration>
配置中找不到绑定类型 wsHttpBinding 实例 wsHttpBinding。下面是WCF web.config代码
<system.serviceModel>
<protocolMapping>
</protocolMapping>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehavior">
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="65536000"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!--添加服务-->
<services>
<!--name必须与代码中的host实例初始化服务一样
behaviorConfiguration配置行为-->
<service behaviorConfiguration="myServiceBehavior" name="WcfService1.Service1">
<!--添加契约接口contract="WcfService1.IService1"为契约接口 binding="wsHttpBinding" wsHttpBinding同为http调用 BasicHttpBinding-->
<endpoint address="" binding="wsHttpBinding" contract="WcfService1.IService1"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
<host>
<baseAddresses>
<!--添加调用服务地址-->
<add baseAddress="http://localhost:1682/"/>
<add baseAddress="http://localhost:1592/"/>
</baseAddresses>
</host>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>下面是ServiceReferences.ClientConfig代码
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="wsHttpBinding_IService1">
<binaryMessageEncoding/>
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="" binding="wsHttpBinding"
contract="WcfService1.IService1"
bindingConfiguration="myServiceBehavior"
name="myServiceBehavior" />
</client>
</system.serviceModel>
</configuration>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货