How to fix an endpoint/configuration error using WCF in VB.NET

Posted by Eric on Stack Overflow See other posts from Stack Overflow or by Eric
Published on 2010-04-12T18:22:09Z Indexed on 2010/04/12 18:22 UTC
Read the original article Hit count: 733

Filed under:
|
|
|
|

I'm working with a small web page that is meant to assist the users of my application. This web page takes a file and sends it to a central server, which then does something with the data and returns a result. I created this application some time ago and am coming back to it recently. I am getting some kind of configuration error right now, although this application used to work.

When it stopped working, whenever I ran the page and sent the data to the central server, I would get this error:

"Could not find default endpoint element that references contract 'CentralService.ICwCentralService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."

Looking at some other issues on the net, I thought I might have had the answer. The service reference to the endpoint was contained in a separate project from the code that called it, but the configuration file in that project had no information about the endpoint.

So, I added these entries to the web.config file in the main project:

<system.serviceModel>
<bindings>
  <wsHttpBinding>
    <binding name="wsHttpEndpoint" closeTimeout="00:01:00" openTimeout="00:0:10"
        receiveTimeout="01:10:00" sendTimeout="01:01:00" bypassProxyOnLocal="false"
        transactionFlow="false" hostNameComparisonMode="StrongWildcard"
        maxBufferPoolSize="999999999" maxReceivedMessageSize="999999999"
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
        allowCookies="false">
      <readerQuotas maxDepth="999999999" maxStringContentLength="999999999" maxArrayLength="999999999"
          maxBytesPerRead="999999999" maxNameTableCharCount="999999999" />
      <reliableSession ordered="true" inactivityTimeout="01:10:00"
          enabled="false" />
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None"
            realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true"
            algorithmSuite="Default" establishSecurityContext="true" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="http://localhost:22269/CwCentralService.svc"
      binding="wsHttpBinding" bindingConfiguration="wsHttpEndpoint"
      contract="CentralService.ICwCentralService" name="wsHttpEndpoint">
    <identity>
      <servicePrincipalName />
    </identity>
  </endpoint>
</client>
</system.serviceModel>

Now, if I run it, I'm still getting an error:

"The remote server returned an unexpected response: (400) Bad Request."

The strange thing is, though, I took those entries from another project that contacts the central server. That application has no problems contacting the central server using these settings. It's not a web page application, but I don't see how that would require these settings to change.

I cannot tell what started causing these errors or when. I assume its something that changed outside of the application (e.g. the libraries referenced) that requires an update to the configuration in the application. I am currently using .NET 3.0 for all of my applications. Any help would be appreciated.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about wcf