Rajaram Shelar
Rajaram Shelar

Reputation: 7877

WCF Service not returning collection in web application

My WCF service is hosted on local IIS. I could not get the result from the wcf call when I call it from the application. But it is strange that it is showing correct result in debugging(while step into the service classes) and returning array of object in the staging classes. and when debugging comes to the application it returns empty array. I have below call from application.

    public List<SurveyQuestion> GetCommonQuestionsForCompentency()
    {
        List<SurveyQuestion> questions = new List<SurveyQuestion>();
        SurveyQuestion[] ques = null;
        ICSSService.SurveyServiceClient client = null;
        try
        {
            client = (SurveyServiceClient)WCFSecurityEntityForSurvey.getSurveyClient();
            ques = client.GetCommonQuestionsByCategoryType(2);
            questions = ques.ToList<SurveyQuestion>();
            return questions;
        }
        catch (Exception)
        {
            throw;
        }
        finally{ client.Close();}
    }

Call in the wcf service class shown below

enter image description here

Whats going wrong with the implementation. Any help?

EDIT :

It is working for a simple service call without list. I think the problem may be in the returning of collection. I found the similar questions Here. But did not get much from this.

Upvotes: 1

Views: 802

Answers (2)

Pradip
Pradip

Reputation: 1537

All you need to do is add a completed function and then add the grid data source to that.

in the page load add

AddHandler client.GetEndorsementCompleted, AddressOf GetEndorsement

then add the following function to let the async function hit.

Private Sub GetEndorsement(ByVal sender As Object, ByVal e As SR.GetEndorsementCompletedEventArgs) If Not e.Result.Equals(Nothing) Then

     'Data grid binding

    End If
End Sub

In case of c# you can using this link from code project that demonstrate

Upvotes: 0

Kitty
Kitty

Reputation: 1065

I have similar problem with this.This is because References are not added correctly and I modified reference.cs file. So data is not gaining correctly if namespaces are different in the application. Just check the namespaces in your application. See if one of the class in your application have different namespace than others

Upvotes: 1

Related Questions