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
{
selfHost.AddServiceEndpoint(
typeof(INumberService),
new WSHttpBinding(SecurityMode.None),
"NumberService");
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
selfHost.Description.Behaviors.Add(smb);
selfHost.Open();
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
selfHost.Close();
}
catch (CommunicationException ce)
{
Console.WriteLine("An exception occurred: {0}", ce.Message);
selfHost.Abort();
}
}
}
}
source
share