3

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>
Aishwarya Shiva
  • 3,460
  • 15
  • 58
  • 107

1 Answers1

2

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

Alex
  • 8,827
  • 3
  • 42
  • 58
  • Actually I was having this http://stackoverflow.com/questions/18400608/how-to-make-wcf-service-server-client-time-difference-independent problem, so I switched to customBinding – Aishwarya Shiva Aug 23 '13 at 19:19
  • Oh, I see that in your case custom binding is a way to go. But is possible to synchronize the clock on server and client? And does you message security exception states same thing as before? – Alex Aug 23 '13 at 21:05
  • ya it states the same thing. Also the time synchronisation can't help. Since those who will install my application might have more time difference then MaxClockSkew, as my application will be downloaded worldwide, so this will restrict them to use my application. That I don't want. I am trying to figure out its solution since two weeks. I am out of options now. Please help. – Aishwarya Shiva Aug 23 '13 at 21:11
  • @AishwaryaShiva It is hard to simulate your problem, so I can only advice you the following. Make shure you have the same binding configuration on both server and client. Make sure you set MaxClockSkew on both client and server. Make sure that you set LocalClientSecuritySettings MaxClockSkew on client side, and LocalServiceSecuritySettings MaxClockSkew on server side. If you do everything, as I've said - it should work. See http://msdn.microsoft.com/en-us/library/aa738468.aspx, suppose it could help you – Alex Aug 24 '13 at 18:49