The CustomBinding on the ServiceEndpoint with contract 'IService1' lacks a TransportBindingElement error when trying to access wcf service

Aishwarya Shiva picture Aishwarya Shiva · Aug 23, 2013 · Viewed 8.2k times · Source

I am trying to access WCF service. But its giving me following error:

The CustomBinding on the ServiceEndpoint with contract 'IService1' lacks a TransportBindingElement. Every binding must have at least one binding element that derives from TransportBindingElement.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The CustomBinding on the ServiceEndpoint with contract 'IService1' lacks a TransportBindingElement. Every binding must have at least one binding element that derives from TransportBindingElement.

Following is my service model full config:

<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>-->

As you can see it already has the Transport Element. But still I am getting above error. What is the reason?

My Client Config:

<?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>

Answer

Alex picture Alex · Aug 23, 2013

Man, I advice you not to do like that. If you use Custom binding on your server, you should use it in your client also. If you use WSHttp on client, your server should have the same binding enpoint. I doubt that you need to create custom binding in your case. In 90% of cases the standart WCF binding would be enought to make a proper solution. Don't develop a new bicycle. As for your second problem, suppose it is the reason of using WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10 in your custom binding, which requires to use certificate for security purposes. Anyway I recommend you to change the custom binding with the WSHttp