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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:12:46+00:00 2026-05-25T15:12:46+00:00

I know how to add a WebReference in Visual Studio, easy enough. I also

  • 0

I know how to add a WebReference in Visual Studio, easy enough.

I also know how to create a normal ASP.NET Web Service project, but that’s not what I am doing here.

So, the WebService I have running looks like this:

try
{
    if (host != null)
    {
         host.Close();
         host = null;
    }
    baseAddress = new Uri("http://example.com:8080");
    host = new WebServiceHost(typeof(MyProxy), baseAddress);

    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
    smb.HttpGetEnabled = true;
    host.Description.Behaviors.Add(smb);

    host.Opened += new EventHandler(host_Opened);
    host.Closed += new EventHandler(host_Closed);

    System.ServiceModel.Description.ServiceEndpoint se = host.AddServiceEndpoint(typeof(IMyProxy), new WebHttpBinding(), baseAddress);
    se.Behaviors.Add(new System.ServiceModel.Description.WebHttpBehavior());
    host.Open();
 }
 catch (Exception e)
 {
 }

 // .... stuff ....

[ServiceContract]
public interface IMyProxy
{
    [OperationContract]
    [WebGet(UriTemplate = "GetArea?searchString={searchString}")]
    GetAreaResult GetArea(string searchString);
}

// more stuff of course follows here

The problem is that when I try to add a WebReference to the above service in Visual Studio, I get an error.

“Add Service Reference” –> “Add Web Reference”
and in the URL I write my URL, http://example.com:8080

Then I get “Service … Endpoint not found.” and the error message in the Add Web Reference box:

There was an error downloading ‘http://example.com:8080/‘. The request
failed with HTTP status 404: Not Found. There was an error downloading
‘http://example.com:8080/$metadata’. The request failed with HTTP
status 404: Not Found.

If I open up a web browser and go directly to http://example.com:8080/GetArea the service is called/executed as expected.

So to rephrase the problem shorter: The WSDL/description isn’t there, so I cannot add a Web Service reference.

  • 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-25T15:12:47+00:00Added an answer on May 25, 2026 at 3:12 pm

    The problem here is that the WebServiceHost will remove the functionality that you are trying to achieve when adding the ServiceMetadataBehavior. Looking in dotPeek (reflector) at the WebServiceHost, inside the OnOpening method there is:

    ServiceDebugBehavior serviceDebugBehavior = this.Description.Behaviors.Find<ServiceDebugBehavior>();
      if (serviceDebugBehavior != null)
      {
        serviceDebugBehavior.HttpHelpPageEnabled = false;
        serviceDebugBehavior.HttpsHelpPageEnabled = false;
      }
      ServiceMetadataBehavior metadataBehavior = this.Description.Behaviors.Find<ServiceMetadataBehavior>();
      if (metadataBehavior != null)
      {
        metadataBehavior.HttpGetEnabled = false;
        metadataBehavior.HttpsGetEnabled = false;
      }
    

    The WebServiceHost is designed to be used with REST/JSON services which typically have no defined contract, hence why metadata (mex) is disabled.

    If you are trying to create a SOAP based service, you need to use a standard ServiceHost. It looks like this is what you want, as you are trying to add the service reference through VS.

    If you are trying to create a REST/JSON service, you can use WebServiceHost.

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

Sidebar

Related Questions

I know how to add SL page as a whole to existing ASP.net application.
Does anyone know how to add a simple search textbox on an ASP.NET Dynamic
Do you know an add-in for visual studio which adds properties for C# projects?
I know I can add a icon to the Resources.resx file of a project
I know I can add service behaviors with some XML configuration, but I'd like
I have successfully created an ASP.net website to make calls to a Soap Web
I know how to add the description through the server management studio. And i
I would like to create a layout like this. I don't know how add
I know add() adds the specified (signed) amount of time to the given time
Why does C++ need and use pointers? I know they add power to the

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.