【问题标题】:WCF service - works locally but returns exception "Bad Data" when publishedWCF 服务 - 在本地工作,但在发布时返回异常“错误数据”
【发布时间】:2013-06-12 15:42:22
【问题描述】:

我正在部署一个基本的 WCF 服务,该服务对数据库执行查询并返回要由 VSTO excel 插件使用的数据。

在本地运行服务进行测试时一切正常,但是一旦插件指向已发布的服务,我就会收到 500 错误“错误数据”(即返回的肥皂包中包含的所有内容)。

发布端的代码和本地一样,通过本地浏览器可以看到服务。发布端是本地网络上另一台运行IIS7.0的机器

客户端配置:

      <binding name="zzzServiceBinding" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="10485760" maxBufferPoolSize="524288" maxReceivedMessageSize="10485760"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="TransportCredentialOnly">
              <transport clientCredentialType="Ntlm" proxyCredentialType="None"
                  realm="" />
              <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
      </binding>

和端点定义:

  <endpoint address="http://_EDITED OUT_/zzz/zzzService.svc"
      binding="basicHttpBinding" bindingConfiguration="zzzServiceBinding"
      contract="zzzService.IzzzService" name="zzzService_Prod" />
  <endpoint address="http://localhost:51149/zzzService.svc"
      binding="basicHttpBinding" bindingConfiguration="zzzServiceBinding"
      contract="zzzService.IzzzService" name="zzzService_Local" />

编辑: 其中一种方法失败 -

    [FaultContract(typeof(Exception))]
    public DataTable GetBranchList(DateTime ReportDate)
    {
        try
        {
            return zzzLibrary.GetBranchList(ReportDate);
        }
        catch (Exception ex)
        {
            throw LogAndThrow(ex);
        }
    }


    protected FaultException LogAndThrow(Exception ex)
    {
        log.Error("Error in the zzz Service.", ex);
        return new FaultException(new FaultReason(ex.Message));
    }

图书馆 -

    public static DataTable GetBranchList(DateTime ReportDate)
    {
        DbInstance db = GetDBConnection();

        try
        {
            string SQLText = "zzzschema.usp_zzzGetBranchList";
            return db.QueryReturningDataTable(SQLText, CommandType.StoredProcedure, db.CreateParameter("@ReportDate", ReportDate));
        }
        finally
        {
            db.Close();
        }
    }

我知道库例程可以正常工作,因为我在单元测试中对其进行了测试,并且在从本地运行的服务调用时它可以正常工作。

【问题讨论】:

  • 网页或 Web 服务上的 HTTP 500 错误是遇到未处理异常的有力指标。您能向我们展示构成该服务的代码吗?
  • 向原始问题添加了一个服务调用,但这又是在本地服务上运行并且可以工作的相同代码。不幸的是,日志记录组件似乎有问题,我也没有得到日志文件:( - 我正在调查的另一个问题。
  • 也许这就是未处理异常的来源。 ;-)
  • 很遗憾不是 :( - 我在没有日志包装器的情况下进行了测试,我得到了相同的错误消息。

标签: c# wcf vsto


【解决方案1】:

删除服务周围的日志记录层后,我可以看到日志记录层不存在的堆栈跟踪。

原来是配置疏忽 - 堆栈跟踪显示我错过了与存储数据库登录详细信息相关的部署脚本。

【讨论】:

    猜你喜欢
    • 2013-09-20
    • 1970-01-01
    • 2019-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-28
    相关资源
    最近更新 更多