2013-03-11 3 views
17

В настоящее время я работаю над проектом C#, который представляет собой консольное приложение, в котором размещено WC-мыло.Самостоятельная служба WCF в Mono

Ниже приведен код, который я использую для открытия хоста.

var baseAddress = new Uri(Configuration.soapServerSettings.soapServerUrl); 
var host = new ServiceHost(typeof(SoapServer), baseAddress); 
BasicHttpBinding basicHttpBinding = new BasicHttpBinding(); 

var meta = new ServiceMetadataBehavior() 
{ 
    HttpGetEnabled = true, 
    HttpGetUrl = new Uri("", UriKind.Relative) 
}; 

host.Description.Behaviors.Add(meta); 

var debugBehaviour = new ServiceDebugBehavior() 
{ 
    HttpHelpPageEnabled = true, 
    HttpHelpPageUrl = new Uri("", UriKind.Relative), 
    IncludeExceptionDetailInFaults = true 
}; 

ServiceEndpoint endpnt = host.AddServiceEndpoint(
    typeof(ISoapInterface), 
    basicHttpBinding, 
    "EmailServer"); 

host.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); 
host.Description.Behaviors.Add(debugBehaviour); 
host.Open(); 

Это работает прекрасно на Windows, но в Linux, когда я получаю я просматриваю к ней я получаю следующее сообщение:

XmlSchema error: Named item http://schemas.microsoft.com/2003/10/Serialization/:anyType was already contained in the schema object table. Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic MS implementation. Related schema item SourceUri: , Line 3, Position 3.

Я понятия не имею, где начать смотреть в эту проблему.

Спасибо за любую помощь вы можете предоставить

Update: По Роб Goodwins предложение, я добавил MONO_STRICT_MS_COMPLIANT как переменную окружения, которая, похоже, работал я могу получить доступ к сервису. Однако сейчас у меня другая проблема. У меня есть страница PHP, которая выполняет несколько запросов каждые пару секунд, но через минуту мое приложение падает.

я получаю следующее исключение:

This XmlWriter does not accept StartTag at this state Error. at System.Xml.XmlTextWriter.WriteStartElement (System.String prefix, System.String localName, System.String namespaceUri) [0x00000] in :0 at System.Xml.DefaultXmlWriter.WriteStartElement (System.String prefix, System.String localName, System.String ns) [0x00000] in :0 at System.Xml.XmlWriter.WriteStartElement (System.String localName, System.String ns) [0x00000] in :0 at System.ServiceModel.Logger.TraceCore (TraceEventType eventType, Int32 id, Boolean hasRelatedActivity, Guid relatedActivity, System.Object[] data) [0x00000] in :0 at System.ServiceModel.Logger.LogMessage (System.ServiceModel.Diagnostics.MessageLogTraceRecord log) [0x00000] in :0 at System.ServiceModel.Logger.LogMessage (MessageLogSourceKind sourceKind, System.ServiceModel.Channels.Message& msg, Int64 maxMessageSize) [0x00000] in :0 at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] in :0 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] in :0 at System.ServiceModel.Dispatcher.MessageProcessingContext.Reply (Boolean useTimeout) [0x00000] in :0 at System.ServiceModel.Dispatcher.OperationInvokerHandler.Reply (System.ServiceModel.Dispatcher.MessageProcessingContext mrc, Boolean useTimeout) [0x00000] in :0 at System.ServiceModel.Dispatcher.OperationInvokerHandler.ProcessRequest (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in :0 at System.ServiceModel.Dispatcher.BaseRequestProcessorHandler.ProcessRequestChain (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in :0 at System.ServiceModel.Dispatcher.BaseRequestProcessorHandler.ProcessRequestChain (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in :0 at System.ServiceModel.Dispatcher.HandlersChain.ProcessRequestChain (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in :0 at System.ServiceModel.Dispatcher.BaseRequestProcessor.ProcessRequest (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in :0

Unhandled Exception: System.InvalidOperationException: This XmlWriter does not accept StartTag at this state Error. at System.Xml.XmlTextWriter.WriteStartElement (System.String prefix, System.String localName, System.String namespaceUri) [0x00000] in :0 at System.Xml.DefaultXmlWriter.WriteStartElement (System.String prefix, System.String localName, System.String ns) [0x00000] in :0 at System.Xml.XmlWriter.WriteStartElement (System.String localName, System.String ns) [0x00000] in :0 at System.ServiceModel.Logger.TraceCore (TraceEventType eventType, Int32 id, Boolean hasRelatedActivity, Guid relatedActivity, System.Object[] data) [0x00000] in :0 at System.ServiceModel.Logger.Log (TraceEventType eventType, System.String message, System.Object[] args) [0x00000] in :0 at System.ServiceModel.Logger.Error (System.String message, System.Object[] args) [0x00000] in :0 at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessErrorWithHandlers (IChannel ch, System.Exception ex, System.ServiceModel.Channels.Message& res) [0x00000] in :0 at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessRequest (IReplyChannel reply, System.ServiceModel.Channels.RequestContext rc) [0x00000] in :0 at System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone (IAsyncResult result) [0x00000] in :0

Я тоже, кажется, не быть в состоянии получить доступ к сервису через VS2010 Client Test WCF, это не ошибка это просто сидит там с индикатором прогресса в 50% и больше не получает.

В журнале ошибок Apache, я получаю следующее сообщение об ошибке:

System.ArgumentException: Should be something like [[hostname:]port:]VPath:realpath at Mono.WebServer.ApplicationServer.AddApplicationsFromCommandLine (System.String applications) [0x00000] in :0 at (wrapper remoting-invoke-with-check) Mono.WebServer.ApplicationServer:AddApplicationsFromCommandLine (string) at Mono.WebServer.Apache.Server.RealMain (System.String[] args, Boolean root, IApplicationHost ext_apphost, Boolean quiet) [0x00000] in :0 at (wrapper remoting-invoke-with-check) Mono.WebServer.Apache.Server:RealMain (string[],bool,Mono.WebServer.IApplicationHost,bool) at Mono.WebServer.Apache.Server.Main (System.String[] args) [0x00000] in :0 [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: Should be something like [[hostname:]port:]VPath:realpath at Mono.WebServer.ApplicationServer.AddApplicationsFromCommandLine (System.String applications) [0x00000] in :0 at (wrapper remoting-invoke-with-check) Mono.WebServer.ApplicationServer:AddApplicationsFromCommandLine (string) at Mono.WebServer.Apache.Server.RealMain (System.String[] args, Boolean root, IApplicationHost ext_apphost, Boolean quiet) [0x00000] in :0 at (wrapper remoting-invoke-with-check) Mono.WebServer.Apache.Server:RealMain (string[],bool,Mono.WebServer.IApplicationHost,bool) at Mono.WebServer.Apache.Server.Main (System.String[] args) [0x00000] in :0

Update 2: я, кажется, это своего рода рабочий в настоящее время, за исключением я могу получить доступ только обслуживание локально. То есть веб-службу можно получить локально, а функции выполняют то, что должны, но я не могу получить к ней доступ с другого ПК. То есть Я пытаюсь получить доступ к службе WCF на сервере Mono с помощью тестового клиента WCF из моего Dev ПК от Dev ПК и я тогда получаю следующий результат:

Error: Cannot obtain Metadata from http://192.168.1.74:6525/ If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://192.168.1.74:6525/ Metadata contains a reference that cannot be resolved: 'http://192.168.1.74:6525/ '.
Content Type application/soap+xml; charset=utf-8 was not supported by service http://192.168.1.74:6525/ . The client and service bindings may be mismatched. The remote server returned an error: (415) Expected content-type 'text/xml; charset=utf-8' but got 'application/soap+xml; charset=utf-8'.HTTP GET Error URI: http://192.168.1.74:6525/ The document was understood, but it could not be processed. - The WSDL document contains links that could not be resolved. - There was an error downloading ' http://localhost:6525/?xsd=xsd0 '. - Unable to connect to the remote server - No connection could be made because the target machine actively refused it 127.0.0.1:6525.

Update 3: При дальнейшем тестирования выглядит так, как если бы многие звонки были сделаны в службу за один раз. Постоянно зависающее обновление на странице браузера, использующее сервис, похоже, разбивает его.

Похоже, что с System.ServiceModel.Logger.TraceCore в Моно что-то не так. Есть ли способ отключить эту часть моно, чтобы я не затронул эту проблему.

+0

Вы пытались использовать совет из своего сообщения об ошибке, установив MONO_STRICT_MS_COMPLIANT на «да»? проверьте это сообщение в блоге http://erictummers.wordpress.com/2012/01/24/wsdl-in-mono/ – vittore

+0

Мне не удалось найти, где это установлено – Boardy

+2

Я считаю, что это переменная окружения –

ответ

1

Возможно, у меня есть некоторые проблемы, связанные с разрешением с сервера хостинга, пожалуйста, отметьте один раз разрешения, предоставленные конкретному порту. Надеюсь, это может быть полезно.

+0

Другие клиенты могут подключиться к нему, хотя, например, клиент тестирования WCF в vs2010 – Boardy