I added a new web service to my console application and I got an exception from the System.ServiceModel namespace:
The exception was: “Could not find default endpoint element that references contract ‘A_RECORD_LOCK.B_RECORD_LOCK’ 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 through the system.serviceModel in the app.config file, I saw that there were no entries for my new web service. So I added them by copying another binding and remaining the appropriate properties:
<textMessageEncoding maxReadPoolSize=”64″ maxWritePoolSize=”16″ messageVersion=”Soap11″ writeEncoding=”utf-8″>
<readerQuotas manyManyProperties=”true” />
<httpTransport lotsOfSettingsCutOut=”true” />
<endpoint address=”http://www.someserver.com/record_lock” binding=”customBinding” bindingConfiguration=”RECORD_LOCK” contract=”A_RECORD_LOCK.A_RECORD_LOCK” name=”RECORD_LOCK” />
But the error persisted. After a few other tries, I decided to actually read the error message carefully. (This tends to help solve problems.) The message stated it couldn’t find the contract “A_RECORD_LOCK.B_RECORD_LOCK”. I looked at the contract property in the endpoint element and saw “A_RECORD_LOCK.A_RECORD_LOCK”. Doh! They were different. After renaming the contract to the correct value, it worked.
Be careful of those contract spelling, kids.