WCF服务-本地工作,但返回异常“坏数据”;当发表
本文关键字:坏数据 数据 异常 -本 服务 工作 返回 WCF | 更新日期: 2023-09-27 18:17:54
我正在部署一个基本的WCF服务,它对数据库执行查询并返回要由VSTO excel插件使用的数据。
在本地运行服务进行测试时一切正常,但是一旦插件指向已发布的服务,我就会得到一个500错误"坏数据"(这就是返回soap包中包含的所有内容)。
发布端代码与本地相同,我可以通过本地浏览器看到服务。发布端是本地网络上运行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));
}
library -
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();
}
}
,我知道库例程可以工作,因为我在单元测试中对它进行了测试,并且当从本地运行的服务调用时它可以工作。
删除服务周围的日志记录层使我能够看到日志记录层不存在的堆栈跟踪。
原来是一个配置疏忽——堆栈跟踪显示我错过了一个与存储数据库登录详细信息相关的部署脚本。