isOneWay WCF服务

时间:2010-10-15 21:09:24

标签: c# asp.net wcf service

我正在尝试创建一个验证数据库中数据并通知用户错误的进程。我最初的想法是创建一个在用户保存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>

2 个答案:

答案 0 :(得分:1)

当在WCF中遇到类似这些问题时,在更改配置时某些东西停止工作时,我肯定会开始追踪正在运行的服务。 WCF有一个很好的跟踪机制,您可以通过编辑配置来开始。您可以阅读有关配置它的所有信息here

答案 1 :(得分:0)

我发现了这个问题。这可能看起来很奇怪,但服务是在同一个项目中运行的,这似乎导致了将其用作单向服务的问题。我把它移到了自己的项目中,一切按预期工作。

我感谢大家的时间,这种追踪肯定会在未来发挥作用。

相关问题