我正在部署一个基本的 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();
}
}
我知道库例程可以工作,因为我在单元测试中对其进行了测试,并且在从本地运行的服务调用时它可以工作。