Boa*_*rdy 17 c# mono wcf self-hosting
我目前正在开发一个C#项目,它是一个控制台应用程序,其中包含一个WCF soap服务.
下面是我用来打开主机的代码.
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();
Run Code Online (Sandbox Code Playgroud)
这在Windows上完全正常,但在Linux上,当我浏览到它时,我收到以下消息:
XmlSchema错误:命名项 http://schemas.microsoft.com/2003/10/Serialization/:anyType已包含在架构对象表中.考虑将MONO_STRICT_MS_COMPLIANT设置为"是"以模仿MS实现.相关架构项SourceUri:,第3行,第3位.
我不知道从哪里开始研究这个问题.
感谢您的任何帮助,您可以提供
更新:
根据Rob Goodwins的建议,我添加了MONO_STRICT_MS_COMPLIANT环境变量,它看起来确实有效,我可以访问该服务.但是,我现在遇到了另一个问题.我有一个PHP页面,它每隔几秒就会发出几个请求,但过了一分钟后,我的应用程序崩溃了.
我得到以下异常:
此XmlWriter在此状态下不接受StartTag错误.在System.Xml.XmlTextWriter.WriteStartElement(System.String前缀,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: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,System.ServiceModel.Logger.LogMessage(System.ServiceModel.Diagnostics.MessageLogTraceRecord log)[0x00000] in:0,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:在System.ServiceModel.Channels.Http.HttpReq中为0 uestContext.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 in 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,System.ServiceModel.D ispatcher.BaseRequestProcessor.ProcessRequest(System.ServiceModel.Dispatcher.MessageProcessingContext mrc)[0x00000] in:0
未处理的异常:System.InvalidOperationException:此XmlWriter在此状态下不接受StartTag错误.在System.Xml.XmlTextWriter.WriteStartElement(System.String前缀,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: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(I ReplyChannel回复,System.ServiceModel.Channels.RequestContext rc)[0x00000] in:0 at System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone(IAsyncResult result)[0x00000] in:0
我似乎也无法通过VS2010 WCF测试客户端访问该服务,它没有错误它只是坐在那里50%的进度条,并没有得到任何进一步.
在apache错误日志中,我收到以下错误:
System.ArgumentException:应该类似[[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)在Mono.WebServer.Apache.Server.RealMain(System.String [] args,布尔根,IApplicationHost ext_apphost,布尔安静)[0x00000] in:0 at(wrapper remoting-invoke- with-check)Mono.WebServer.Apache.Server:Mono.WebServer.Apache.Server.Main(System.String [] args)[0x00000]中的RealMain(string [],bool,Mono.WebServer.IApplicationHost,bool) :0 [错误]致命未处理的异常:System.ArgumentException:应该类似于[[hostname:] port:] VPath:在Mono.WebServer.ApplicationServer.AddApplicationsFromCommandLine(System.String应用程序)[0x00000]中的realpath:0 at( wrapper remoting-invoke-with-check)Mono.WebServer.ApplicationServer:AddApplicationsFromCommandLine(string)a t 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.服务器:RealMain(string [],bool,Mono.WebServer.IApplicationHost,bool)在Mono.WebServer.Apache.Server.Main(System.String [] args)[0x00000] in:0
更新2: 我似乎现在有点工作,除了我只能在本地访问服务.即,可以在本地访问Web服务,并且功能可以执行它们应该执行的操作,但是我无法从另一台PC访问它.即我试图从开发PC的开发PC使用WCF测试客户端访问Mono服务器上的WCF服务,然后我得到以下输出:
错误:无法从中获取元数据
http://192.168.1.74:6525/如果这是您有权访问的Windows(R)Communication Foundation服务,请检查您是否已在指定地址启用元数据发布.有关启用元数据发布的帮助,请参阅http://go.microsoft.com/fwlink/?LinkId=65455上的MSDN文档 .WS-http://192.168.1.74:6525/Metadata Exchange错误URI:元数据包含无法解析的引用:'http://192.168.1.74:6525/'.
内容类型application/soap + xml; 服务不支持charset = utf-8http://192.168.1.74:6525/.客户端和服务绑定可能不匹配.远程服务器返回错误:(415)预期内容类型'text/xml; charset = utf-8'但得到了'application/soap + xml; charset = utf-8'.HTTP GET错误URI:http://192.168.1.74:6525/文档已被理解,但无法处理. - WSDL文档包含无法解析的链接.- 下载'http://localhost:6525/?xsd=xsd0'时出错. - 无法连接到远程服务器 - 无法建立连接,因为目标计算机主动拒绝它127.0.0.1:6525.
更新3: 经过进一步测试,看起来好像一次拨打多次电话.使用该服务不断地在浏览器页面上进行刷新似乎会使其崩溃.
System.ServiceModel.Logger.TraceCoreMono内部看起来好像有问题.有没有办法禁用这部分单声道,所以我不会受到这个问题的影响.
| 归档时间: |
|
| 查看次数: |
4541 次 |
| 最近记录: |