我正在尝试访问 WCF 服务。但它给了我以下错误:
带有合同“IService1”的 ServiceEndpoint 上的 CustomBinding 缺少 TransportBindingElement。每个绑定必须至少有一个从 TransportBindingElement 派生的绑定元素。
说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.InvalidOperationException:具有合同“IService1”的 ServiceEndpoint 上的 CustomBinding 缺少 TransportBindingElement。每个绑定必须至少有一个从 TransportBindingElement 派生的绑定元素。
以下是我的服务模型完整配置:
<system.serviceModel>
<!-- change -->
<bindings>
<customBinding>
<binding name="Wrabind" closeTimeout="00:02:00" openTimeout="00:02:00">
<transactionFlow />
<security authenticationMode="SecureConversation" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<localClientSettings maxClockSkew="00:07:00" />
<localServiceSettings maxClockSkew="00:07:00" />
<secureConversationBootstrap messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<localClientSettings maxClockSkew="00:30:00" />
<localServiceSettings maxClockSkew="00:30:00" />
</secureConversationBootstrap>
</security>
<textMessageEncoding />
<httpTransport authenticationScheme="Anonymous" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" proxyAuthenticationScheme="Anonymous" realm="" useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
<!-- change -->
<services>
<service behaviorConfiguration="WCFService.Service1Behavior"
name="WCFService.Service1">
<endpoint address="http://subdomain.domain.com/service1.svc" binding="customBinding"
bindingName="Wrabind" contract="WCFService.IService1" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFService.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="false" />
<!-- change -->
<!--<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WrangleCoreService.Authentication.DistributorValidator, WrangleCoreService"/>
<serviceCertificate findValue="WCFService" storeLocation="LocalMachine" storeName="TrustedPeople" x509FindType="FindBySubjectName"/>
</serviceCredentials>-->
<!-- change -->
<!-- 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>
<baseAddressPrefixFilters>
<add prefix="http://subdomain.domain.com/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<!--<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true"
automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>-->
如您所见,它已经具有传输元素。但我仍然在错误之上。是什么原因?
我的客户端配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="CustomBinding_IService1" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://subdomain.domain.com/service1.svc" binding="wsHttpBinding"
bindingConfiguration="CustomBinding_IService1" contract="ServiceReference1.IService1"
name="CustomBinding_IService1">
<identity>
<userPrincipalName value="DOMAIN\subdomaindomaincom_web" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>