views:

51

answers:

0

Hi,

I'm having trouble with my WCF Service. I want my method to return a list formatted in JSON.

When i invoke the method, my response is empty. Even when i set the method's BodyStyle to be Wrapped.

It works if i return null, the output then becomes:

null

and with BodyStyle set to Wrapped:

{
    VerwerkStatus: null
}

If i debug and watch the list there are 87 items or if i return list.Count(), i get 87, so the list is not empty.

I suspect it is currently only working when i return one integer or string value. If i return 1 VerwerkStatus object, it doesn't work either.

The service is hosted in a ASP.NET Website project running on ASP.NET 3.5. The VerwerkStatus object is a Entity object so it is serializable.

My code:

/// <summary>
/// 
/// </summary>
/// <param name="sessie"></param>
/// <param name="verwerkStatusId"></param>
/// <returns></returns>
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json)]
public List<VerwerkStatus> Status(string sessie, int verwerkStatusId)
{
    if (!String.IsNullOrEmpty(sessie))
    {
        Guid sessieGuid = new Guid(sessie);
        var status = statusRepository.GetStatus(sessieGuid, verwerkStatusId);
        var list = status.ToList();
        // list.Count() == 87
        // none in browser
        return list;
    }
    else
    {
        return null;// "FOUT: Geen sessie";
    }
}

and Web.Config:

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <behaviors>
        <endpointBehaviors>
            <behavior name="SheetProcessServiceAspNetAjaxBehavior">
                <webHttp />
            </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="SheetProcessServiceAspNetAjaxBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service name="SheetProcessService" behaviorConfiguration="SheetProcessServiceAspNetAjaxBehavior">
            <endpoint address="" behaviorConfiguration="SheetProcessServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="SheetProcessService" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
</system.serviceModel>

I just can't get it to work..