[英]isOneWay WCF Services
我试图创建一个过程来验证数据库中的数据并通知用户错误。 我最初的想法是创建一个在用户保存Web表单时触发的Web服务。 该Web服务将开始验证数据并向另一个表填充有关它认为哪些信息无效的信息的过程。 从一开始,我就打算让该Web服务在实际完成数据验证之前立即返回。 数据验证将是一个较长的过程,并不旨在进行表单验证。 如果发生故障也是可以的,因为该过程还将在每天晚上刷新,因此我对此并不担心。
OneWay服务似乎是最合理的选择。 我已经写了该服务,并且在没有OneWay的情况下一切都很好。 但是,当我添加OneWay时,该过程将不再起作用。 让我特别困惑的是,我有一行代码在Web服务方法的最开始输出一个日志文件,并且在我调用该服务时偶尔会写入日志。 并非每次都如此,但有时。 我也有多个输出的日志语句,并且一旦启用isOneWay,它就永远不会超过第一行。 似乎该代码只是被任意暂停。 有人遇到过吗? 我的下一个选择是创建一个网络队列任务,该任务直接接收Web服务调用并将其添加到其队列中,我希望避免这样做。
背景信息,我是WCF服务的新手,但一般来说不是Web服务。 该Web应用程序是用ASP.Net编写的,并且正在通过HttpGet调用Web服务。
我愿意接受其他体系结构建议,我们将不胜感激。
这是来自web.config的ServiceModel元素:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="WebHttpBinding_Service">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport authenticationScheme="Negotiate,Ntlm"/>
</binding>
</customBinding>
<webHttpBinding>
<binding name="webHttpBinding_IISAuthen">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="Namespace.Service" behaviorConfiguration="Namepsace.ServiceBehavior">
<endpoint address="" behaviorConfiguration="Namespace.ServiceAspNetAjaxBehavior"
binding="webHttpBinding" bindingConfiguration="webHttpBinding_IISAuthen" contract="Namespace.Service" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="Namespace.ServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Namespace.ServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<client>
<endpoint binding="customBinding" bindingConfiguration="WebHttpBinding_Service"
contract="Service" name="WebHttpBinding_Service" />
</client>
</system.serviceModel>
当遇到WCF中的此类问题(在更改配置时某些操作停止)时,我肯定会从跟踪正在运行的服务开始。 WCF具有出色的跟踪机制,您可以通过编辑配置开始。 您可以在此处阅读有关配置它的所有信息。
我发现了问题。 可能看起来很奇怪,但是服务是在同一个项目中运行的,这似乎导致了将其用作单向服务的问题。 我将其移至自己的项目中,一切都按预期工作。
我感谢每个人所花费的时间,在将来肯定会有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.