简体   繁体   English

isOneWay WCF服务

[英]isOneWay WCF Services

I'm attempting to create a process that verifies data within a database and notifies users of errors. 我试图创建一个过程来验证数据库中的数据并通知用户错误。 My initial thought was to create a web service that is triggered when the user saves the web form. 我最初的想法是创建一个在用户保存Web表单时触发的Web服务。 That web service would begin the process of validating the data and populating another table with information about what information it believes is invalid. 该Web服务将开始验证数据并向另一个表填充有关它认为哪些信息无效的信息的过程。 From the beginning I had intended for this web service to return instantly prior to the actual completition of the data verification. 从一开始,我就打算让该Web服务在实际完成数据验证之前立即返回。 The data verification is going to be a longer process and isn't intended to be form validation. 数据验证将是一个较长的过程,并不旨在进行表单验证。 It's also okay if it were to happen to fail since the process will be refreshed every evening also so I'm not concerned about that. 如果发生故障也是可以的,因为该过程还将在每天晚上刷新,因此我对此并不担心。

OneWay services seems like the most logical choice for this. OneWay服务似乎是最合理的选择。 I have already written the service and everything is working great without OneWay being present. 我已经写了该服务,并且在没有OneWay的情况下一切都很好。 However the moment I add OneWay the process no longer works. 但是,当我添加OneWay时,该过程将不再起作用。 What is particularly puzzling to me is I have a line that outputs a log file at the very beginning of the web service method and it occasionally writes the log when I call the service. 让我特别困惑的是,我有一行代码在Web服务方法的最开始输出一个日志文件,并且在我调用该服务时偶尔会写入日志。 Not every time, but sometimes. 并非每次都如此,但有时。 I also have multiple log statements that get outputted and it has never made it past the first line once isOneWay is enabled. 我也有多个输出的日志语句,并且一旦启用isOneWay,它就永远不会超过第一行。 It seems like the code is just being arbitrarily halted. 似乎该代码只是被任意暂停。 Has anyone ever run into this before? 有人遇到过吗? My next option is to create a network queue task that receives the web service call directly and adds it to its queue and I was hoping to avoid doing that. 我的下一个选择是创建一个网络队列任务,该任务直接接收Web服务调用并将其添加到其队列中,我希望避免这样做。

A bit more background information, I am new to WCF services but not web services in general. 背景信息,我是WCF服务的新手,但一般来说不是Web服务。 The web application is written in ASP.Net and is calling the webservice via HttpGet. 该Web应用程序是用ASP.Net编写的,并且正在通过HttpGet调用Web服务。

I'm open to other architecture suggestions and any input is greatly appreciated. 我愿意接受其他体系结构建议,我们将不胜感激。

Here is the ServiceModel element from the web.config: 这是来自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>

When running into problems like these in WCF, where something stops working when changing the configuration, I would definitely start by tracing the running service. 当遇到WCF中的此类问题(在更改配置时某些操作停止)时,我肯定会从跟踪正在运行的服务开始。 WCF has a great tracing mechanism which you start by editing the configuration. WCF具有出色的跟踪机制,您可以通过编辑配置开始。 You can read all about configuring it here . 您可以在此处阅读有关配置它的所有信息。

I discovered the problem. 我发现了问题。 It may seem odd but the service was being run within the same project and that seemed to be causing the problem with using it as a one way service. 可能看起来很奇怪,但是服务是在同一个项目中运行的,这似乎导致了将其用作单向服务的问题。 I moved it out into its own project everything worked as expected. 我将其移至自己的项目中,一切都按预期工作。

I thank everyone for their time, the tracing will certainly prove to be useful in the future. 我感谢每个人所花费的时间,在将来肯定会有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM