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

  • SEARCH
  • Home
  • 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 8319745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:25:12+00:00 2026-06-08T22:25:12+00:00

I am developing an wcf-webservice. The consumer is able to choose between an atom-response

  • 0

I am developing an wcf-webservice. The consumer is able to choose between an atom-response and a json-response.

My OperationContract looks like this:

[OperationContract]
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "json/json")]
    Result GetData();

The Result-Type contains some strings and an array of entries.

 [DataContract]
public class Result
{
    [DataMember]
    public string baseUrl;
    [DataMember]
    public string url;
    [DataMember]
    public string title;
    [DataMember]
    public int totalResults;
    [DataMember]
    public JsonEntries[] resources;
}

I marked the JsonEntries also as DataContract:

  [DataContract]
public class JsonEntries
{
    [DataMember]
    public string updated;
    [DataMember]
    public string key;
    [DataMember]
    public string title;
    [DataMember]
    public Salary salarie;
}

However, when i am trying to run this i get the error, that the metadata could not be called. When I am deleting the [DataMember] in front of the array, i get no error, but my response doesnt contain the array.
I’ve seen it work like this on various exmaples. So what am i doing wrong?

thanks in advance.

robidd

  • 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-06-08T22:25:13+00:00Added an answer on June 8, 2026 at 10:25 pm

    Should work, here is my code sample

    DataContracts

    [DataContract]
    public class Result
    {
        [DataMember]
        public int totalResults;
        [DataMember]
        public JsonEntries[] resources;
    }
    
    [DataContract]
    public class JsonEntries
    {
        [DataMember]
        public string title;
    }
    

    OperationContract

    [OperationContract]
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "getdata")]
    Result GetData();
    
        public Result GetData()
        {
            var jsonEntries = new List<JsonEntries>
                {
                    new JsonEntries {title = "1"},
                    new JsonEntries {title = "2"},
                    new JsonEntries {title = "3"}
                }.ToArray();
            return new Result
            {
                resources = jsonEntries,
                totalResults = 1
            };
        }
    

    my get call

        private Bag<T> GetData<T>(string uri)
        {
            try
            {
                var request = (HttpWebRequest) WebRequest.Create(uri);
                request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                request.Headers[HttpRequestHeader.Authorization] = _authorizationData;
                var response = (HttpWebResponse) request.GetResponse();
                Stream stream = response.GetResponseStream();
                var localStream = new MemoryStream();
                CopyStream(stream, localStream);
                stream.Close();
                var result = JsonContractExtensions.Create<T>(localStream);
                return new Bag<T>(result);
            }
            catch (WebException ex)
            {
                _log.Debug(ex);
                return Bag<T>.Empty;
            }
            catch (Exception ex)
            {
                _log.Debug(ex);
                return Bag<T>.Empty;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a RESTful webservice using WCF. I would like to have a
What is the difference between developing WCF service by opening a console application project(generally)
I'm currently developing a WCF service (Service.svc) and I would like to consume it
I plan to start developing with WCF this weekend. Before i get too far
I'm developing a WCF Service with a custom UserNamePasswordValidator with a basicHttpBinding. This configuration,
I'm developing a WCF service that accepts parameters in JSON. I cant' figure out
Greetings, in our company we are developing wcf service. This is used as a
I'm developing a RESTful WCF, and am currently having trouble getting nice, clean JSON-serialized
I am developing a WCF service which can be consumed by mobile applications to
I am developing a WCF service which will be consumed by multiple different client

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.