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 8046337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:45:30+00:00 2026-06-05T05:45:30+00:00

I has a problem with WCF. The first application I wrote the example from

  • 0

I has a problem with WCF.
The first application I wrote the example from the site this. It worked good.
I need to make an application to transfer objects from the server list from the database. But when I get a list of the client, the following CommunicationException:

An error occurred while receiving the HTTP response to (localhost:8080).
This could be due to the service endpoint binding not using the HTTP protocol.
This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down).
See server logs for more details.

Server worked good or I do not understand something.

If you need information (code) on the project will be, I will give it

Sorry for my English.

UPD:
config:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="Habra.Server.MobilePosts" behaviorConfiguration="MyBehavior">
        <endpoint
            address=""
            binding="basicHttpBinding"
            contract="Habra.Core.IMobilePosts" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

server code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Habra.Server
{
    using System.ServiceModel;

    public class Program
    {
        public static void Main(string[] args)
        {
            Type serviceType = typeof(MobilePosts);
            Uri serviceUri = new Uri("http://localhost:8080/");
            ServiceHost host = new ServiceHost(serviceType, serviceUri);
            host.Open();

            foreach (Uri uri in host.BaseAddresses)
            {
                Console.WriteLine("\t{0}", uri.ToString());
            }

            Console.WriteLine();
            Console.WriteLine("Number of dispatchers listening : {0}", host.ChannelDispatchers.Count);
            foreach (System.ServiceModel.Dispatcher.ChannelDispatcher dispatcher in host.ChannelDispatchers)
            {
                Console.WriteLine("\t{0}, {1}", dispatcher.Listener.Uri.ToString(), dispatcher.BindingName);
            }

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate Host");
            Console.ReadLine();
        }
    }
}

UPD2:
fails in:

MobilePostsClient mpc = new MobilePostsClient();
var list = mpc.GetAllPosts();

MobilePostClient created by Add Service Reference.

UPD3:
IMobilePosts:

[ServiceContract]
public interface IMobilePosts
{
    [OperationContract]
    List<Post> GetAllPosts();

    [OperationContract]
    FullPost GetFullPost(int postId);
}

MobilePosts:

public class MobilePosts : IMobilePosts
{
    private readonly IRepository repository = new RepositoryQueries();

    public List<Post> GetAllPosts()
    {
        var list = this.repository.GetAllPosts();

        foreach (Post post in list)
        {
            Console.WriteLine(post.Title + " loading...");
        }

        return list;
    }

    public FullPost GetFullPost(int postId)
    {
        return this.repository.GetFullPostById(postId);
    }
}

Repositories worked correct.

  • 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-05T05:45:31+00:00Added an answer on June 5, 2026 at 5:45 am

    Did you set attributes to Post class properties?

    [DataContract]
    public class Post
    {
        [DataMember]
        public string Post{get;set;}
    

    You can trace all messages with ServiceBehavior read more here.
    i.e. put attribute to servie

    [SilverlightFaultAttribute]
    public class MobilePosts : IMobilePosts        
    {...}
    

    and set trace output to file

    using System;
    using System.Diagnostics;
    using System.IO;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.ServiceModel.Channels;
    using System.ServiceModel.Description;
    using System.ServiceModel.Dispatcher;
    using System.Xml;
    
    namespace Wcf
    {
    public class SilverlightFaultAttribute : Attribute, IServiceBehavior
    {
        #region IServiceBehavior Members
    
        public void AddBindingParameters(ServiceDescription serviceDescription,
            ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection<ServiceEndpoint> endpoints,
            BindingParameterCollection bindingParameters)
        {
    
        }
    
        public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            Trace.WriteLine(" */*/*/* ApplyDispatchBehavior");
    
            foreach (var t in serviceHostBase.ChannelDispatchers)
            {
                var channelDispatcher = t as ChannelDispatcher;
                if ((channelDispatcher == null)) continue;
                foreach (var dispatcher2 in channelDispatcher.Endpoints)
                {
                    var dispatchRuntime = dispatcher2.DispatchRuntime;
                    dispatchRuntime.MessageInspectors.Add(new SilverlightFaultMessageInspector());
                }
            }
        }
        public class SilverlightFaultMessageInspector : IDispatchMessageInspector
        {
            public void BeforeSendReply(ref Message reply, object correlationState)
            {
                if (reply.IsFault)
                {
                    Trace.WriteLine(" */*/*/* reply.IsFault");
                    Trace.WriteLine(reply);
                    var property = new HttpResponseMessageProperty();
    
                    // Here the response code is changed to 200.
                    property.StatusCode = System.Net.HttpStatusCode.OK;
    
                    reply.Properties[HttpResponseMessageProperty.Name] = property;
    
                    MessageBuffer buffer = reply.CreateBufferedCopy(Int32.MaxValue);
                    Message copy = buffer.CreateMessage();  // Create a copy to work with
                    reply = buffer.CreateMessage();         // Restore the original message 
    
                    object faultDetail = ReadFaultDetail(copy);
                    Exception exception = faultDetail as Exception;
                    Trace.WriteLine(exception);
                }
            }
    
            public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
            {
                // Do nothing to the incoming message.
                return null;
            }
    
            private static object ReadFaultDetail(Message reply)
            {
                const string detailElementName = "Detail";
                using (XmlDictionaryReader reader = reply.GetReaderAtBodyContents())
                {
                    // Find <soap:Detail>
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element && reader.LocalName == detailElementName)
                        {
                            break;
                        }
                    }
    
                    // Did we find it?
                    if (reader.NodeType != XmlNodeType.Element || reader.LocalName != detailElementName)
                    {
                        return null;
                    }
                    // Move to the contents of <soap:Detail>
                    if (!reader.Read())
                        return null;
                    // Deserialize the fault
                    NetDataContractSerializer serializer = new NetDataContractSerializer();
                    try
                    {
                        return serializer.ReadObject(reader);
                    }
                    catch (FileNotFoundException)
                    {
                        // Serializer was unable to find assembly where exception is defined 
                        return null;
                    }
                }
            }
        }
    
        public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
        }
    
        #endregion
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem has bugged me so many times and i have now decided to
This problem has happened to me twice.Both times during programming with Borland C++.when i
This problem has been solved! Thanks a lot to Brad, Denis and junkie! You're
Premise This problem has a known solution (shown below actually), I'm just wondering if
This Jquery problem has been bugging me for a while now. I developed a
EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
My hardware has a problem, from time to time it's sending a keydown followed
you will think: "This problem has been solved many, many times. So why doesn't
at first I want to make my apologize for my english I've a problem
I'm having a problem using WCF Data Services for an entity that has a

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.