1

我按照此处的说明进行操作:http: //msdn.microsoft.com/en-us/library/ms731774 (v=vs.110).aspx ,但绑定时出现错误。配置

    <bindings>
  <wsHttpBinding>
    <binding name="wsHttpBinding_Inventory">
      <security mode="Message">
        <message clientCredentialType="UserName"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<services>
  <service name="Viopsys.API.V_1_0.Inventory" behaviorConfiguration="MyServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8732/Viopsys.API/V_1_0/Inventory" />
      </baseAddresses>
    </host>
    <endpoint address="PurchaseOrder" binding="wsHttpBinding_Inventory" contract="Viopsys.API.V_1_0.IPurchaseOrder">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
  </service>
</services>

错误

System.Configuration.ConfigurationErrorsException: Configuration binding extension 'system.serviceModel/bindings/wsHttpBinding_Inventory' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.
   at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.ServiceModel.Activation.AspNetEnvironment.UnsafeGetSectionFromConfigurationManager(String sectionPath)
   at System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetAssociatedSection(ContextInformation evalContext, String sectionPath)
   at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, String configurationName)
   at System.ServiceModel.ServiceHost.ApplyConfiguration()
   at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)
   at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(Type type, ServiceKind kind)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)
4

1 回答 1

3

我想说链接的 MSDN 文章中有一个错误。他们将 bindingConfiguration 放入 binding 属性中。正确的端点配置如下所示:

<endpoint address="PurchaseOrder" 
          binding="wsHttpBinding" 
          bindingConfiguration="wsHttpBinding_Inventory"
          contract="Viopsys.API.V_1_0.IPurchaseOrder">
  <identity>
    <dns value="localhost" />
  </identity>
</endpoint>

MSDN 文章中甚至还有另一个错误(您已经做对了):他们将绑定定义为

<bindings>
  <WSHttpBinding>
   ...
  </WSHttpBinding>
</bindings>

但它必须是

<bindings>
  <wsHttpBinding>
   ...
  </wsHttpBinding>
</bindings>
于 2013-04-04T18:17:58.020 回答