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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:20:49+00:00 2026-06-19T03:20:49+00:00

In my book, it wants me to expose two endpoints using two bindings: WsHttpBinding

  • 0

In my book, it wants me to expose two endpoints using two bindings: WsHttpBinding & NetTCPBinding and host the service in a host application.

I use the following code in C# to try to connect to my service:

Uri BaseAddress = new Uri("http://localhost:5640/SService.svc");

Host = new ServiceHost(typeof(SServiceClient), BaseAddress);
ServiceMetadataBehavior Behaviour = new ServiceMetadataBehavior();
Behaviour.HttpGetEnabled = true;
Behaviour.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
Host.Description.Behaviors.Add(Behaviour);
Host.Open();

On the service side I have:

[ServiceContract]
public interface IService...

public class SService : IService....

Then in my Config file I have:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>

    <behaviors>
      <serviceBehaviors>
        <behavior name="Behavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <services>
      <service behaviorConfiguration="WsHttpBehaviour" name="SService.SService">

        <endpoint
          address=""
          binding="wsHttpBinding"
          bindingConfiguration="WsHttpBindingConfig"
          contract="SService.IService" />

        <endpoint
          address=""
          binding="netTcpBinding"
          bindingConfiguration="NetTCPBindingConfig"
          contract="SService.IService" />

        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:5640/SService.svc" />
            <add baseAddress="net.tcp://localhost:5641/SService.svc" />
          </baseAddresses>
        </host>

      </service>
    </services>

  </system.serviceModel>
</configuration>

But when I try to add service reference to my host application, it says unable to download metadata from the address. I don’t understand what is wrong and the teacher never taught this.. I decided to go ahead and look it up and learn ahead of time. I used the Editor to create the WebConfig shown above.

Can anyone point me in the right direction? I added Metadata behaviour through the editor and I set the HttpGetEnabled to true.

  • 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-19T03:20:50+00:00Added an answer on June 19, 2026 at 3:20 am

    I can find a few issues with your code that can cause this issue:

    Host = new ServiceHost(typeof(SServiceClient), BaseAddress). Pass here typeof(SService.SService) instead of typeof(SServiceClient). Change like this:

    Host = new ServiceHost(typeof(SService.SService))
    

    <service behaviorConfiguration="WsHttpBehaviour". I guess this should be “Behavior” as you have defined that. Since you have metadata enabled in config, you may remove the lines of code which add a ServiceMetadataBehavior to your servicehost.

    Here is a sample that you can use for reference:

    <system.serviceModel>
        <services>
          <service name="ConsoleApplication1.Service">
            <endpoint address="" binding="wsHttpBinding" contract="ConsoleApplication1.IService" />
            <endpoint address="" binding="netTcpBinding" contract="ConsoleApplication1.IService" />
            <host>
              <baseAddresses>
                <add baseAddress="http://<machinename>:5640/SService.svc" />
                <add baseAddress="net.tcp://<machinename>:5641/SService.svc" />
              </baseAddresses>
            </host>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="False"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                ServiceHost host = new ServiceHost(typeof(Service));
                host.Open();
    
                Console.ReadLine();
            }
        }
    
        [ServiceContract]
        public interface IService
        {
            [OperationContract]
            string DoWork();
        }
    
        public class Service : IService
        {
            public string DoWork()
            {
                return "Hello world";
            }
        }
    }
    

    Metadata will be automatically available at the http baseaddress defined in the config.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to ensure that there are no duplicate book titles in the following
i want to develop the blog application which is described in the book ASP.NET
My User model is using has_secure_password (based on the Rails tutorial Book ): schema.rb:
I have the following structure in a form: <div class='full'> <div class='half'> <label>Book</label> <select
I'm having trouble understanding how to use ORM generated objects. We're using LLBLGen for
Take the following example: class BookManager { ... }; class Book { public: void
Let's say you have a web application that manages books for book sellers, and
I am working on a web application that will make extensive use of AJAX
I have read the service container chapter in the Symfony2 book multiple times and
I have an application architecture which has following layers (or c# projects). web front

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.