2014-02-18 6 views
2

У меня есть клиент и сервер .NET, который работает с использованием NetTcpBinding в Windows с Microsoft .NET Framework.WCF - Mono-сервер с клиентом Microsoft .NET

Я хочу разрешить запуск сервера в Linux, используя Mono 3.2.7. Однако, когда клиент Microsoft .NET пытается вызвать метод на сервере Mono, то получите сообщение об ошибке:

Не удается связаться с агентом 192.168.0.XX: Ошибка в десериализации тела ответного сообщения для работы 'MyMethod. Для пустого пространства имен требуется нулевой или пустой префикс .

Пустое пространство имен требует пустого или пустого префикса.

Я охотился, но не могу понять, как это исправить.

* Обновление *

Я просто попытался его с BasicHttpBinding вместо этого, и снова он отлично работает с Microsoft .NET Framework - но он по-прежнему не будет работать с Mono. Я получаю подобную ошибку в одном я получаю с NetTcpBinding:

Невозможно переопределить пространство имен для префикса «», используемого в текущем элементе

Сервер дает этот трассировки стека:

Exception Cannot redefine the namespace for prefix '' used at current element at System.Xml.XmlTextWriter.WriteEndAttribute() [0x0028e] in /home/user/mono/mono/mcs/class/System.XML/System.Xml/XmlTextWriter2.cs:995 
    at System.Xml.DefaultXmlWriter.WriteEndAttribute() [0x00000] in /home/user/mono/mono/mcs/class/System.XML/System.Xml/DefaultXmlWriter.cs:116 
    at System.Xml.XmlSimpleDictionaryWriter.WriteEndAttribute() [0x00000] in /home/user/mono/mono/mcs/class/System.Runtime.Serialization/System.Xml/XmlSimpleDictionaryWriter.cs:97 
    at System.Xml.XmlWriter.WriteAttributeString (System.String prefix, System.String localName, System.String ns, System.String value) [0x00025] in /home/user/mono/mono/mcs/class/System.XML/System.Xml/XmlWriter.cs:270 
    at System.Xml.XmlWriter.WriteAttributeString (System.String localName, System.String value) [0x00000] in /home/user/mono/mono/mcs/class/System.XML/System.Xml/XmlWriter.cs:254 
    at System.Xml.XmlDictionaryWriter.WriteXmlnsAttribute (System.String prefix, System.String namespaceUri) [0x00077] in /home/user/mono/mono/mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryWriter.cs:396 
    at System.Runtime.Serialization.DataContractSerializer.WriteStartObject (System.Xml.XmlDictionaryWriter writer, System.Object graph) [0x0022f] in /home/user/mono/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs:501 
    at System.Runtime.Serialization.XmlObjectSerializer.WriteObject (System.Xml.XmlDictionaryWriter writer, System.Object graph) [0x00000] in /home/user/mono/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs:113 
    at System.ServiceModel.Dispatcher.DataContractMessagesFormatter+DataContractBodyWriter.WriteMessagePart (System.Xml.XmlDictionaryWriter writer, System.ServiceModel.Description.MessageBodyDescription desc, System.ServiceModel.Description.MessagePartDescription partDesc, System.Object obj) [0x00049] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:503 
    at System.ServiceModel.Dispatcher.DataContractMessagesFormatter+DataContractBodyWriter.OnWriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00054] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:486 
    at System.ServiceModel.Channels.BodyWriter.WriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00000] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BodyWriter.cs:57 
    at System.ServiceModel.Channels.SimpleMessage.OnWriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00000] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:331 
    at System.ServiceModel.Channels.Message.WriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00022] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:183 
    at System.ServiceModel.Channels.Message.WriteBody (System.Xml.XmlDictionaryWriter writer) [0x0001c] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:168 
    at System.ServiceModel.Channels.Message.OnWriteMessage (System.Xml.XmlDictionaryWriter writer) [0x00065] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:293 
    at System.ServiceModel.Channels.Message.WriteMessage (System.Xml.XmlDictionaryWriter writer) [0x00026] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:195 
    at System.ServiceModel.Channels.TextMessageEncoder.WriteMessage (System.ServiceModel.Channels.Message message, System.IO.Stream stream) [0x0004a] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs:122 
    at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00034] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:139 
    at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:101 
    at System.ServiceModel.Dispatcher.MessageProcessingContext.Reply (Boolean useTimeout) [0x00026] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageProcessingContext.cs:96 
    at System.ServiceModel.Dispatcher.OperationInvokerHandler.Reply (System.ServiceModel.Dispatcher.MessageProcessingContext mrc, Boolean useTimeout) [0x0001d] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationInvokerHandler.cs:69 
    at System.ServiceModel.Dispatcher.OperationInvokerHandler.ProcessRequest (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00044] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationInvokerHandler.cs:29 
    at System.ServiceModel.Dispatcher.BaseRequestProcessorHandler.ProcessRequestChain (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessorHandler.cs:15 
    at System.ServiceModel.Dispatcher.BaseRequestProcessorHandler.ProcessRequestChain (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00017] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessorHandler.cs:16 
    at System.ServiceModel.Dispatcher.HandlersChain.ProcessRequestChain (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x0000b] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessor.cs:72 
    at System.ServiceModel.Dispatcher.BaseRequestProcessor.ProcessRequest (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00018] in /home/user/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessor.cs:26 

Очевидно, что-то связано с сериализацией, но больше, чем я не знаю.

Я активировал Wireshark, чтобы увидеть, как выглядят данные на проводе, и HTTP POST, отправленный на сервер Windows, и сервер Mono выглядят точно так же.

+0

На Mono вы должны быть осторожны, какие рамки на выбор. Например, Web API лучше поддерживается, чем WCF, NHibernate лучше, чем EF. Это связано с прирожденным природой, а не с предвзятым отношением к структурам. Если бы у Моно было достаточно ресурсов, они должны были бы сделать все, чтобы работать. –

+0

WCF был намного дольше, чем веб-API, поэтому я бы подумал, что он будет работать даже с базовой привязкой HTTP без обеспечения безопасности :(Я уже использую WCF в Windows, поэтому было бы нецелесообразно добавлять веб-API Кроме того, мне нужно, чтобы служба была самостоятельной. – Cocowalla

ответ

0

Были 2 части к получать эту работу (раздражающе, оба из которых требуется только на Mono - не Microsoft .NET):

  1. Набор IsReference истину на атрибуте классов DataContract пошлешь на проводе: [DataContract(IsReference = true)]

  2. ли не установить пространство имен на атрибут DataContract на этих классах

+0

Я должен добавить, что это без транспорта или безопасности сообщений, которые я не смог получить с сертификатами и NetTcpBinding или BasicHttpBinding. Я уступаю поражение и полностью отказываюсь от Mono : '( – Cocowalla

Смежные вопросы