Pavan Kumar

Pavan Kumar

  • NA
  • 68
  • 14.9k

How to Solve the "WCF Rest Service Interface Error".

Nov 13 2014 6:57 AM

Hi Friends,

                In our Project we are working WPF with MVVM using Linq and WCF Rest Services.

We are facing some problem in WCF Rest Service .We are creating Interface like below,

[OperationContract]

[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]

 

[FaultContract(typeof(DEErrorProvider))]

Tuple<ObservableCollection<DEEmployee>, DEErrorProvider> getEmploteeList();

 

In above Mark Line in ResponseFormat if we are using Json means we are getting the below Error

 

"The underlying connection was closed: The connection was closed unexpectedly."

 

If we use Xml in ResponesFormat it is working fine. But we need JSON Format.

 

 

In BL we are creating Method like below.

 

      public Tuple<ObservableCollection<DEEmployee>, DEErrorProvider> getEmploteeList ()

        {

            ContactCollection = new ObservableCollection<DEEmployeet>();

            ErrorCollection = new DEErrorProvider();

            try

            {

                using (EmployeeEntities EmpEntity = new EmployeeEntities())

                {

                    Here we are creating our Business Logic with Linq Query Collection.

                }

                ErrorCollection.ErrorResult = true;

            }

             catch (Exception ex)

            {

                ErrorCollection.ErrorMessage = ex.Message;

                ErrorCollection.ErrorTrace = ex.StackTrace;

                ErrorCollection.ErrorResult = false;

            }

            return new Tuple<ObservableCollection<DEEmployee>, DEErrorProvider>(EmployeeCollection, ErrorCollection);

        }

 

 

Please help me to solve this problem.

 


Answers (2)