나는이 문제를 리눅스와 OS X에서 모두 시도했지만 동일한 문제가있다. Mono의 가장 안정적인 버전 인 MonoDevelop 2.6입니다. 내 Mac에서는 2.10.2입니다.Mono의 WCF 서비스에 액세스 할 수 없습니까?
며칠 전에 사용 했었습니다. 브라우저에서 "http : // localhost : 8000/number/test"를 가리키고 "명령 줄에 svcutil http : // localhost : 8000/number/test [somethingmore]와 같이 입력하십시오. "
는 이제 브라우저에서 리눅스와 Mac에서 모두 얻을 메시지는 다음과 같습니다
<Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none">
a:InternalServiceFault
서버가 내부 오류로 인해 요청을 처리 할 수 없습니다. 서버가 예외 세부 정보를 반환 할 수도 있습니다 (서버 설정에 따라 다름).
이것은 이전에 사용 되었기 때문에 중요한 것이 없는지, 아니면 모노가 잘못되어 있는지 잘 모르겠습니다. 나는 당신이 생각하기를 바랍니다. 이것은 MSDN 튜토리얼 (일부 변경 사항이 있음)에서 모두 바로 알 수 있습니다.
(알고 계시지 만, 아직까지 세션을 설정하지 않았기 때문에 지금까지 상태를 저장할 수 없다는 것을 알고 있습니다.이 오류가 발생했을 때 거기에 도착하려고했습니다.)
여기 내 클래스는 다음과 같습니다
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();
}
}
}
}
Windows 7에서 작동합니다. - Visual Studio AND Mono –