Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6372059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:10:57+00:00 2026-05-25T01:10:57+00:00

I got a problem on using WCF service and Entity Model with together. I

  • 0

I got a problem on using WCF service and Entity Model with together. I have created an Entity Model from my existing database. This can be shown below;

enter image description here

There isn’t any problem while using my classes in any console applicaton coming from “Entity Object Code Generator”.

Then, I created WCF Service with Interface Below:

    [ServiceContract]
public interface IAuthorServices
{
    [OperationContract]
    [WebGet( UriTemplate="GetNews")]
    List<Newspaper> GetNews();

    [OperationContract]
    [WebGet(BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetAuthors")]
    List<Author> GetAuthors();

    [OperationContract]
    [WebGet(BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetAuthorTexts")]
    List<AuthorText> GetAuthorTexts();

    [OperationContract]
    [WebGet(BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetTodaysTexts")]
    List<AuthorText> GetTodaysTexts();

    [OperationContract]
    [WebGet(BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetExceptions")]
    List<KoseYazilari.Exception> GetExceptions();

}

However when I implement these methods in a service class and run my client application, I got an error like

enter image description here

How can I get rid of this problem?

Regards,
KEMAL

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:10:58+00:00Added an answer on May 25, 2026 at 1:10 am

    Are your entities marked with a DataContract attribute? Are you making sure that they are serializable?

    EDIT: By looking at your code it seems that you are using your entities directly. This is not a good practice because (even if your code was working) I don’t think you want extra properties like the ones that Entity Framework auto-generates.

    In these case you should consider to use DTOs (Data Transfer Objects), this is an example of how Newspaper class could be:

    [DataContract]
    public class NewspaperDTO
    {
        public NewspaperDTO(Newspaper newspaper)
        {
            this.Name = newspaper.Name;
            this.Image = newspaper.Image;
            this.Link = newspaper.Link;
            this.Encoding = newspaper.Encoding;
        }
    
        [DataMember]
        public string Name { get; set; }
    
        [DataMember]
        public string Image { get; set; }
    
        [DataMember]
        public string Link { get; set; }
    
        [DataMember]
        public string Encoding { get; set; }
    }
    

    And then in your service:

    public List<NewspaperDTO> GetNews()
    {
        return entities.Newspapers.Select(a => new NewspaperDTO(a)).ToList();
    }
    

    P. S. I have noticed that your entities are not disposed (inside the WCF service I mean). You should consider using a pattern like this in every method of your service:

    public List<NewspaperDTO> GetNews()
    {
        using (var entities = new MyEntities())
        {
            return entities.Newspapers.Select(a => new NewspaperDTO(a)).ToList();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a WCF WebHttp Service using the following article as a guideline..
I created a new wcf rest service using .net 4. I have created a
I got a usual WCF service set up like this: private ServiceHost serviceHost =
I have a strange little issue with a WCF RIA service I'm using in
I have been technically testing a WCF service recently and have got to the
Problem Background I'm building a custom WCF Data Service provider using the Alex James
I've got a WCF service using a HttpBinding. The service is running in a
I've got this problem with completed events not firing for WCF long running calls
i have using WCF service in my code that the client(WindowsFormsApplication1) capturing desktop view
I've got a WCF service that's using file-less activation: <bindings> <basicHttpBinding> <binding transferMode=Streamed> <security

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.