ServiceEndpoint上具有约定';IService1';尝试访问wcf服务时缺少Transport
本文关键字:服务 wcf Transport 访问 IService1 约定 ServiceEndpoint | 更新日期: 2023-09-27 18:28:58
我正在尝试访问WCF服务。但它给了我以下错误:
约定为"IService1"的ServiceEndpoint上的CustomBinding缺少TransportBindingElement。每个绑定必须至少有一个从TransportBindingElement派生的binding元素。
描述:在执行期间发生未处理的异常当前web请求。请查看堆栈跟踪以了解更多信息有关错误的信息以及错误在代码中的来源。
异常详细信息:System.InvalidOperationException:CustomBinding在约定为"IService1"的ServiceEndpoint上缺少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>
伙计,我建议你不要那样做。如果您在服务器上使用自定义绑定,那么您也应该在客户端中使用它。如果您在客户端上使用WSHttp,那么您的服务器应该具有相同的绑定点。我怀疑您是否需要在您的情况下创建自定义绑定。在90%的情况下,标准的WCF绑定足以做出正确的解决方案。不要开发新自行车。至于您的第二个问题,假设这是在您的自定义绑定中使用WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary 2005WSSecurityPolicy11BasicSecurityProfile10的原因,该绑定需要使用证书来实现安全目的。无论如何,我建议您使用WSHttp 更改自定义绑定