0

I'm trying to develop an WCF service but I got several errors one by one WCFTestClient is pooping out and I'm trying solving them all day long looking into several tutorials and reading posts here, but this I can't figure out why it's happening, what I'm doing wrong and how can I solve it. But first of all, environment, I'm in development process in visual studio 2013, debugging, nowhere in IIS or somewhere else nothing is hosted. By now it looks something like this:
WCF service project
Models: EntityFramework model, nothing big just one table for experiments which is coming from my local DB which is on development PC.
WebService: WCF web service which I'm trying to develop all day long without success by now. In IPersonService class code is something like this:

[ServiceContract]
public interface IPersonService
{
    [OperationContract]
    List<tblUsers> GetPersons();
}

In PersonService.svc code is something like this:

public class PersonService : IPersonService
{
    public List<tblUsers> GetPersons()
    {
        using (var db = new PersonsEntities())
        {
            return db.tblUsers.ToList();
        }
    }
}

The magical configuration, which is puzzled together all day long from various posts whose I found here:

<bindings>
  <basicHttpBinding>
    <binding name="BindingConfig" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="01:50:00" openTimeout="01:50:00" sendTimeout="01:50:00" receiveTimeout="01:50:00" >
      <readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="PersonSvcBehavior">
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceMetadata httpGetEnabled="true" />
      <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
    </behavior>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service behaviorConfiguration="PersonSvcBehavior" name="WebService.PersonService">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BindingConfig"
      name="PersonSvcBasicHttpBinding" contract="WebService.IPersonService" />
    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="BindingConfig"
      name="PersonSvcMexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:1569/webservice" />
      </baseAddresses>
    </host>
  </service>
</services>

And at the beautiful end I got this, still talking about metadata, but what I do know that I got that MetadataExchange:
enter image description here

John
  • 127
  • 1
  • 13

1 Answers1

2

Look at your mex endpoint as shown below, specifically the bindingConfiguration part which is totally wrong cause that binding configuration is for basicHttpBinding whereas in this endpoint you are using different binding mexHttpBinding.

<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="BindingConfig"
  name="PersonSvcMexHttpBinding" contract="IMetadataExchange" />

Remove the part bindingConfiguration="BindingConfig" and it should just be

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

Moreover the biggest issue with your configuration is your address <add baseAddress="http://localhost:1569/webservice" /> which is not correct. It should be <add baseAddress="http://localhost:1569/PersonService" />.

So change your <Services> part to be like below

<services>
  <service behaviorConfiguration="PersonSvcBehavior" name="WebService.PersonService">
    <endpoint address="PersonService" binding="basicHttpBinding" bindingConfiguration="BindingConfig"
      name="PersonSvcBasicHttpBinding" contract="WebService.IPersonService" />
    <endpoint address="mex" binding="mexHttpBinding"  contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:1569/" />
      </baseAddresses>
    </host>
  </service>
</services>
Rahul
  • 76,197
  • 13
  • 71
  • 125
  • Thanks moved a bit forward, got an error that it cant find entity "connectionString" added that to configuration and, now I'm back to "The maximum message size quota for incoming messages (65536) has been exceeded. " ERROR I thought that I solved that with that "BindingConfig" stuff – John Jan 06 '16 at 19:22
  • @John, that's a separate question altogether and there are already many answered question present in So for that. Go through them like http://stackoverflow.com/questions/16265725/wcf-error-the-maximum-message-size-quota-for-incoming-messages-65536-has-bee and http://stackoverflow.com/questions/19564047/wcf-the-maximum-message-size-quota-for-incoming-messages-65536-has-been-exceed. If still error persist then post a new question for that. – Rahul Jan 06 '16 at 19:28