2013-03-11 32 views
17

Tôi hiện đang làm việc trên một dự án C# là một ứng dụng giao diện điều khiển có dịch vụ xà phòng WCF được lưu trữ bên trong nó.Dịch vụ WCF tự lưu trữ trong Mono

Dưới đây là mã tôi đang sử dụng để mở máy chủ.

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(); 

Đây là hoạt động hoàn toàn tốt đẹp trên Windows nhưng trên Linux khi tôi nhận được tôi duyệt đến nó tôi nhận được thông báo sau:

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.

Tôi không có ý tưởng để bắt đầu nhìn vào vấn đề này đâu.

Nhờ sự giúp đỡ bạn có thể cung cấp

Cập nhật: Theo Rob Goodwins gợi ý, tôi đã thêm MONO_STRICT_MS_COMPLIANT như biến môi trường mà dường như đã làm việc tôi có thể truy cập dịch vụ. Tuy nhiên, bây giờ tôi đang gặp phải một vấn đề khác. Tôi có một trang PHP thực hiện vài yêu cầu vài giây một lần nhưng sau một phút, ứng dụng của tôi bị treo.

tôi nhận được ngoại lệ sau đây:

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

Tôi cũng dường như không thể truy cập dịch vụ qua VS2010 WCF Kiểm tra Client, nó không lỗi nó chỉ ngồi đó với thanh tiến trình ở 50% và không nhận thêm bất kỳ chi tiết nào.

Trong nhật ký lỗi apache tôi nhận được lỗi sau:

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

Cập nhật 2: tôi dường như có nó loại trừ việc bây giờ tôi chỉ có thể truy cập dịch vụ tại địa phương. I E. các dịch vụ web có thể được truy cập tại địa phương và các chức năng làm những gì họ cần, nhưng tôi không thể truy cập nó từ một máy tính khác. I E. Tôi cố gắng để truy cập vào các dịch vụ WCF trên máy chủ Mono sử dụng kiểm tra khách hàng WCF từ PC dev của tôi từ dev PC và sau đó tôi nhận được kết quả như sau:

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.

Cập nhật 3: Sau khi tiếp tục thử nghiệm nó có vẻ như khi có nhiều cuộc gọi được thực hiện vào dịch vụ trong một lần. Thường xuyên ghét làm mới trên trang trình duyệt làm cho việc sử dụng dịch vụ dường như làm hỏng nó.

Dường như có sự cố với số System.ServiceModel.Logger.TraceCore trong Mono. Có cách nào để vô hiệu hóa phần này của mono vì vậy tôi không bị ảnh hưởng bởi vấn đề này.

+0

Bạn đã cố gắng sử dụng lời khuyên từ thông báo lỗi của mình chưa, đặt MONO_STRICT_MS_COMPLIANT thành có? kiểm tra bài đăng trên blog này http://erictummers.wordpress.com/2012/01/24/wsdl-in-mono/ – vittore

+0

Tôi chưa thể tìm thấy nơi này được đặt – Boardy

+2

Tôi tin rằng đó là biến môi trường –

Trả lời

1

Dường như có thể có một số vấn đề liên quan đến quyền của tôi từ máy chủ lưu trữ, vui lòng kiểm tra một lần để có các quyền được cấp cho cổng cụ thể. Hy vọng điều này có thể hữu ích.

+0

Các ứng dụng khách khác có thể kết nối với nó, ví dụ như trình kiểm tra WCF trong vs2010 – Boardy