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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:39:26+00:00 2026-05-26T17:39:26+00:00

What I’d like to have is regular WCF service calls responding on my root

  • 0

What I’d like to have is “regular” WCF service calls responding on my root URL as well as the regular RIA stuff. Seems simple, but is turning out to be a bit of a pain. The RIA stuff works including ODATA JSON and SOAP, but the traditional web services doesn’t want to run off the root URL.

See the following code:

using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server;
using System.ServiceModel.Web;
using Microsoft.ServiceModel.DomainServices.Hosting;

namespace ConsoleApplication1
{
    public partial class Program
    {
        [EnableClientAccess, ServiceContract]
        public class TestDomainService : DomainService
        {
            [Query(IsDefault = true)]
            public IQueryable<Foo> GetAllFoos()
            {
                return new Foo[] { new Foo { Id = 1, Name = "Jonathan" } }.AsQueryable();
            }

            [WebInvoke(Method="GET"), OperationContract]
            public Message Test()
            {
                return WebOperationContext.Current.CreateTextResponse("Test");
            }
        }

        public class Foo
        {
            [Key]
            public int Id { get; set; }
            public string Name { get; set; }
        }

        static void Main(string[] args)
        {
            var baseUri = new Uri("http://localhost:999");

            var svc = new DomainServiceHost(typeof(TestDomainService), new Uri[] { baseUri });
            svc.Description.Behaviors.RemoveAll<AspNetCompatibilityRequirementsAttribute>();
            svc.Description.Behaviors.OfType<ServiceMetadataBehavior>().First().HttpGetEnabled = true;

            var svcDescription = DomainServiceDescription.GetDescription(typeof(TestDomainService));
            var odataEndpoints = new ODataEndpointFactory().CreateEndpoints(svcDescription, svc);
            var soapEndpoints = new SoapXmlEndpointFactory().CreateEndpoints(svcDescription, svc);
            var jsonEndpoints = new JsonEndpointFactory().CreateEndpoints(svcDescription, svc);

            var odata = odataEndpoints.First();
            odata.Contract.Namespace = new Uri(baseUri, "ODATA").ToString();
            odata.Address = new System.ServiceModel.EndpointAddress(new Uri(baseUri, "ODATA"));

            var soap = soapEndpoints.First();
            soap.Contract.Namespace = new Uri(baseUri, "SOAP").ToString();
            soap.Address = new System.ServiceModel.EndpointAddress(new Uri(baseUri, "SOAP"));

            var json = jsonEndpoints.First();
            json.Contract.Namespace = new Uri(baseUri, "JSON").ToString();
            json.Address = new System.ServiceModel.EndpointAddress(new Uri(baseUri, "JSON"));

            var ep = new ServiceEndpoint(svc.Description.Endpoints[0].Contract, new WebHttpBinding(), new EndpointAddress(baseUri));
            ep.Behaviors.Add(new WebHttpBehavior());
            var cd = ContractDescription.GetContract(typeof(TestDomainService));
            foreach (var op in cd.Operations)
            {
                if (ep.Contract.Operations.Any(o => o.Name == op.Name) == false)
                {
                    ep.Contract.Operations.Add(op);
                }
            }
            svc.Description.Endpoints.Add(ep);

            svc.Description.Endpoints.Add(odata);
            svc.Description.Endpoints.Add(soap);
            svc.Description.Endpoints.Add(json);

            svc.Open();

            foreach (var endpoint in svc.Description.Endpoints)
            {
                Console.WriteLine("Domain service started on: {0}", endpoint.Address.Uri);
            }

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }
}

Accessing http://localhost:999/Test should result in just Test being displayed, but instead I get:

<Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none">
    <Code>
        <Value>Sender</Value>
        <Subcode>
            <Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</Value>
        </Subcode>
    </Code>
    <Reason>
        <Text xml:lang="en-US">The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</Text>
    </Reason>
</Fault>

Can anyone see what I’m missing?

Thanks in advance!

  • 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-26T17:39:27+00:00Added an answer on May 26, 2026 at 5:39 pm

    For me, I just needed to return raw strings on that endpoint so I implemented my own HttpBehavior and DispatchFormatter as such:

        public class WebHttpBehaviorEx : WebHttpBehavior
        {
            protected override IDispatchMessageFormatter GetReplyDispatchFormatter(OperationDescription operationDescription, ServiceEndpoint endpoint)
            {
                return new DynamicFormatter();
            }
        }
    
        public class DynamicFormatter : IDispatchMessageFormatter
        {
            public void DeserializeRequest(Message message, object[] parameters)
            {
                throw new NotImplementedException();
            }
    
            public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
            {
                return WebOperationContext.Current.CreateTextResponse((result ?? string.Empty).ToString());
            }
        }
    

    and changed

    ep.Behaviors.Add(new WebHttpBehavior());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I have two tables with like below codes: Table: Accounts id | username |
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,

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.