WCF单向调用未执行

本文关键字:执行 调用 WCF | 更新日期: 2023-09-27 18:21:11

我有一个WCF服务,它的方法用[OperationContract(IsOneWay=true)]装饰。

[ServiceContract]
public interface IService
{
    [OperationContract(IsOneWay=true)]
    void DoThis(DateTime value);
} 

当我调用此方法时,没有引发异常。然而,WCF方法内部没有执行任何操作,例如数据库操作(插入、更新…)

我错过了什么?

我的WCF配置

<system.serviceModel>
    <bindings>
          <basicHttpBinding>
              <binding closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
                 maxBufferSize="50000000" maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000">
                  <readerQuotas maxDepth="500000000" maxStringContentLength="500000000" maxArrayLength="500000000"
                        maxBytesPerRead="500000000" maxNameTableCharCount="500000000" />
              </binding>
          </basicHttpBinding>
      </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- 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="true"/>
      <dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="6553600"/>
      <serviceThrottling maxConcurrentCalls="500" maxConcurrentInstances="500" maxConcurrentSessions="500"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

我如何呼叫我的服务:

MyService proxy = new MyService();
proxy.DoThis(DateTime.Now);

其他WCF方法按预期工作,只是没有[OperationContract(IsOneWay=true)]。

提前谢谢。

WCF单向调用未执行

我通过打开跟踪发现了这个问题。由于这是一个单向调用,所以客户端不会识别任何异常或响应。

谢谢大家。