Mono WCF service unavailable?

I tried this on both linux and os x, and I have the same problem. This is MonoDevelop 2.6 with the latest stable version of Mono. On my Mac thats v 2.10.2.

This worked for me a few days ago. I would point my browser to โ€œhttp: // localhost: 8000 / number / testโ€ and get a message saying something like โ€œAt the command prompt, type svcutil http: // localhost: 8000 / number / test [somethingmore] "

Now the message I get on both Linux and Mac in the browser:

<Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none">

<Code> a: InternalServiceFault Code> The server was unable to process the request due to an internal error. The server can return exception information (it depends on the server settings).         

This worked, so I'm not sure if I am missing something important or something is wrong with Mono or something else. Hope you have an idea. This is almost as straight from the MSDN tutorial (with some changes).

(For those who know, I know that this cannot save state yet, because it is not configured for sessions yet, I worked to get there when I received this error).

Here are my classes:

using System;
using System.ServiceModel;

namespace NumberService
  {
[ServiceContract]
public interface INumberService
{
    [OperationContract]
    void Add(int val);

    [OperationContract]
    void Subtract(int val);

    [OperationContract]
    int Result();
}
}

using System;

namespace NumberService
{
public class NumberService : INumberService
{
    private int val = 1;


    public NumberService ()
    {
        Console.WriteLine("NumberService created.");
    }

    public void Add(int val)
    {
        this.val += val;    
    }

    public void Subtract(int val)
    {
        this.val -= val;
    }


    public int Result()
    {
        return val;
    }
}
}



using System;
using System.ServiceModel;
using System.ServiceModel.Description;

namespace NumberService
{
class MainClass
{
    public static void Main (string[] args)
    {
        Uri uri = new Uri("http://localhost:8000/number/test");

        ServiceHost selfHost = new ServiceHost(typeof(NumberService), uri);


        try
        {


            // Step 3 of the hosting procedure: Add a service endpoint.
            selfHost.AddServiceEndpoint(
                typeof(INumberService),
                new WSHttpBinding(SecurityMode.None),
                "NumberService");


            // Step 4 of the hosting procedure: Enable metadata exchange.
            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            selfHost.Description.Behaviors.Add(smb);

            // Step 5 of the hosting procedure: Start (and then stop) the service.
            selfHost.Open();
            Console.WriteLine("The service is ready.");
            Console.WriteLine("Press <ENTER> to terminate service.");
            Console.WriteLine();
            Console.ReadLine();

            // Close the ServiceHostBase to shutdown the service.
            selfHost.Close();
        }
        catch (CommunicationException ce)
        {
            Console.WriteLine("An exception occurred: {0}", ce.Message);
            selfHost.Abort();
        }


    }


}
}
+5
source share
1 answer

Did you try to access the service while debugging? From InternalServiceFaultit seems that something is causing the service to fail.

Niklas

+1
source

All Articles