1

I've created a simple WCF service for an application that I'm currently working on using DevExtreme.

To test my service, I use Postman, provided from the google play store thing.

The server starts up fine. If I debug my function GetLogins()I can see that Postman invokes this function, but I'm not receiving the return value.

IService.cs:

[ServiceContract]
public interface IService
{
    [OperationContract]
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "/logins")]
    List<Login> GetLogins();
}

Service.cs:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service : IService
{
    //Returns all Logins
    public List<Login> GetLogins()
    {
        var list = DAO.Instance.Login.ToList();
        return list;
    }
}

App.config:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
  <service name="HourRegistrationWCF.Service">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8733/Design_Time_Addresses/HourRegistrationWCF/Service/" />
      </baseAddresses>
    </host>
    <!-- Service Endpoints -->
    <!-- Unless fully qualified, address is relative to base address supplied above -->
    <endpoint address=""
              binding="webHttpBinding"
              contract="HourRegistrationWCF.IService"
              behaviorConfiguration="REST">
      <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <!-- Metadata Endpoints -->
    <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
    <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="REST">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
      <!-- 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>
<bindings>
  <webHttpBinding>
    <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true"/>
  </webHttpBinding>
</bindings>

I can't seem to find the problem.

Postman response

enter image description here

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Detilium
  • 2,868
  • 9
  • 30
  • 65
  • If you put debugger at GetLogins() method in server side is control flow coming there? i mean will it hit to debugger ? – CodeGuru Aug 11 '15 at 06:33
  • @Popeye Yes it will. I can even see the 1 `Login`I have in the db. Postman just isn't receiving it. – Detilium Aug 11 '15 at 06:34
  • 1
    can you check your Login class whether you have defined it as Data Contract and fields of it as Data Members . – CodeGuru Aug 11 '15 at 06:37
  • Excuse me for my rookie flaws, but I'm not sure what you mean? – Detilium Aug 11 '15 at 06:40
  • Please also check this http://stackoverflow.com/questions/17644392/configuring-wcf-rest-services-in-web-config for configurations, i think you are missing some behavior configurations. Check all configurations once. – CodeGuru Aug 11 '15 at 06:41
  • I mean to say, you are returning List so Login class is your data Contract. Please check here http://www.codeproject.com/Articles/664238/Understanding-Contracts-in-WCF – CodeGuru Aug 11 '15 at 06:45
  • I tried the link you sent me, but no success. Still not getting the return value – Detilium Aug 11 '15 at 06:51
  • The Login class is straight from the db, using entity framework. The strange thing is that I had this working with a previous WCF service, using the EXACT same configurations (except for the names ofcourse), so I can't see why it shouldn't work now. – Detilium Aug 11 '15 at 06:58
  • @Popeye after looking at my configuration and making sure everything is fine, it's still not working. – Detilium Aug 11 '15 at 07:17
  • Fixet it by turning the `ProxyCreationEnabled` to `false` in the db context. It had some problem with the serialization – Detilium Aug 11 '15 at 07:40

0 Answers0