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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:24:16+00:00 2026-06-09T03:24:16+00:00

I have written a WCF web service ( not a web site, just JSON

  • 0

I have written a WCF web service (not a web site, just JSON over HTTP) intended to run in Azure. I need to write tests for it.

I know how to do this, but it seems amateurish:

  1. Run the web service,
  2. Copy the root URL (e.g. http://localhost:81/)
  3. Apply the root URL to my test project,
  4. Run the test project.

I would like to be able to do this:

  1. Hit F5
  2. –> web service starts running
  3. –> tests start running, automatically finding where IIS decided to run the service.

Is there a way?

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

    There are 2 ways you can do this. Since you’re using Windows Azure I assume you’re using the emulator. Using the emulator means that the RoleEnvironment is available and you can get a list of roles, their instances, and their endpoints that are available.

    var endpoint = RoleEnvironment.Roles["WebRole1"].Instances.First().InstanceEndpoints["Endpoint1"];
    var siteUrl = String.Format("{0}://{1}", endpoint.Protocol, endpoint.IPEndpoint);
    

    This code will get the role named WebRole1, get the first instance on this role (you could use this to test if your web service supports load balancing) and get the InstanceEndpoint. The instance endpoint will give you all info you need like protocol (http/https) and the IP/port (these are things you configure in the ServiceConfiguration).

    Note: This also works for processes running outside the emulator (like your test project). The only thing you’ll need to do is reference Microsoft.WindowsAzure.ServiceRuntime.

    Besides that you can also try to use the ServerManager class to find the current sites running in IIS, but I don’t think this will work if you’re running in IIS Express (which is also possible if you’re working with Azure).

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

Sidebar

Related Questions

I have written a simple WCF web service in C# which returns records from
I have written a simplified Silverlight client library for my WCF web service using
I have written a java axis2 1.4.1 web service and .net 3.5 WCF client
I have written a simple WCF web service which is configured programmaticaly. It exposes
I have written a REST service with windows azure using the WCF Rest Service
We run a web application with many (50+) WCF service hosts (Written in C#,
Here is my situation. I have written a WCF service which calls into one
I have written a simple WCF service that accepts and stores messages. It works
I have written a very simple WCF service, that worked fine (code below), then
I'm building a WCF service, I have written the contract in the IService file

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.