title: Self-hosted SOAP Service C#.Net
body: <p>I have an application which should host a service. The service is implementing an <code>Interface</code> likes this:</p>
  
  <pre><code>    [ServiceContract]
      public interface IRegistrationCaseFetcherService
      {
          [OperationContract]
          bool CancelTransaction(string transactionControlNumber);
  
          [OperationContract]
          bool ConfirmTransaction(string transactionControlNumber);
  
          [OperationContract]
          bool UpdateTransaction(string transactionControlNumber, UpdatedRegistrationCase personData);
  
          [OperationContract]
          bool checkEndPoint();
      }
  </code></pre>
  
  <p>My Service is defined like this:</p>
  
  <pre><code>    [ServiceBehavior(UseSynchronizationContext = false)]
      public class RegistrationCaseFetcherService : IRegistrationCaseFetcherService
      {
          static int CallsInProgress = 0;
  
          public bool CancelTransaction(string transactionControlNumber)
          {
              return true;
          }
  
          public bool ConfirmTransaction(string transactionControlNumber)
          {
              return true;
          }
  
          public bool UpdateTransaction(string transactionControlNumber, UpdatedRegistrationCase personData)
          {
              return true;
          }
  
          public bool checkEndPoint()
          {
              return true;
          }
  
  
          public static bool IsInUse
          {
              get
              {
                  return (CallsInProgress != 0);
              }
          }
      }
  </code></pre>
  
  <p>I do also have a class to trigger this service:</p>
  
  <pre><code>  public static class Services
    {
              private static ServiceHost _service;
              private static bool _isHosted = false;
  
              public static bool StartRecieveService()
              {
                  var address = string.Format("http://{0}:8732/Services/RService", Dns.GetHostName());
  
                  _service = new ServiceHost(typeof(RegistrationCaseFetcherService), new Uri(address));
                  _service.AddServiceEndpoint(typeof(IRegistrationCaseFetcherService), new BasicHttpBinding(), address);
  
                  var serviceMetaDataBehaviour = _service.Description.Behaviors.Find&lt;ServiceMetadataBehavior&gt;();
                  if (serviceMetaDataBehaviour == null) serviceMetaDataBehaviour = new ServiceMetadataBehavior();
                  serviceMetaDataBehaviour.HttpGetEnabled = true;
                  serviceMetaDataBehaviour.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
  
                  _service.Description.Behaviors.Add(serviceMetaDataBehaviour);
  
                  try
                  {
                      _service.Open();
                      _isHosted = true;
                      if (_service.BaseAddresses.Count &gt; 0)
                          _logger.Trace(String.Format("Waiting for incomming calls on: {0}", _service.BaseAddresses[0].AbsoluteUri));
                      return true;
                  }
                  catch (Exception e)
                  {
                      _logger.Error("Failed with exception: " + e);
                      return false;
                  }
              }
          }    
  </code></pre>
  
  <p>It seems that the service is being triggered when I debug, no exceptions are thrown. By opening the URL in my Web browser doesn't work, it says that the resource do not exist somehow. I also tried opening it in the <code>WCF Test Client</code>, but then I do get <code>Error: Cannot Obtain Metadata</code>.</p>
  
  <p>How is it possible for me to actually verify that my service is up and running? And what changes in my code should I do to get it work? </p>
  
  <p>Thanks in advance  </p>