提问人:Shanu Garg 提问时间:6/9/2021 最后编辑:JackdawShanu Garg 更新时间:6/26/2021 访问量:154
WCF 服务 SSRS 通过浏览器上的 URL 工作,但在 WCF 客户端上不起作用?
WCF Service SSRS works via URL on my browser but not on WCF Client?
问:
在我的客户端上使用用户名和密码进行 NTLM 身份验证,我可以在浏览器上登录,但通过 WCF SSRS 使用的报告不起作用。
请参阅随附的代码。
生成报告功能
public byte[] GenerateReport(string reportName, ReportingService.ExportFormat format,IList<MyApplicationService.ParameterValue> parameters, out string mimeType)
{
byte[] output;
string extension, encoding;
const string reportDirectory = "/Reports/";
MyApplicationService.Warning[] warnings;
string[] streamIds;
ReprotServ.ReportExporter.Export("basicHttpEndpoint", new NetworkCredential("Username", "Password"),
reportDirectory + reportName, parameters.ToArray(), format, out output, out extension, out mimeType, out encoding, out warnings, out streamIds);
return output;
}
public static void Export(
string wcfEndpointConfigName, System.Net.NetworkCredential clientCredentials, string report, ParameterValue[] parameters,
ExportFormat format, out byte[] output, out string extension, out string mimeType, out string encoding, out Warning[] warnings, out string[] streamIds)
{
var webServiceProxy = new MyApplicationService.ReportExecutionServiceSoapClient(wcfEndpointConfigName);
try
{
webServiceProxy.ClientCredentials.Windows.AllowedImpersonationLevel =
System.Security.Principal.TokenImpersonationLevel.Impersonation;
webServiceProxy.ClientCredentials.Windows.ClientCredential = clientCredentials;
// Init Report to execute
ServerInfoHeader serverInfoHeader;
ExecutionInfo executionInfo;
ExecutionHeader executionHeader = webServiceProxy.LoadReport(null, report, null, out serverInfoHeader, out executionInfo);
// Attach Report Parameters
webServiceProxy.SetExecutionParameters(executionHeader, null, parameters, null, out executionInfo);
// Render
serverInfoHeader =
webServiceProxy.Render(executionHeader, null, GetExportFormatString(format), null,
out output, out extension, out mimeType, out encoding, out warnings,
out streamIds);
webServiceProxy.Close();
}
catch (CommunicationException e)
{
webServiceProxy.Abort();
throw new CommunicationException(e.Message);
}
finally
{
webServiceProxy.Close();
}
Web 配置文件
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ReportExecutionServiceSoap" receiveTimeout="10:00:00" sendTimeout="10:00:00" allowCookies="true" maxReceivedMessageSize="5242880">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://xyz:80/ReportServer/ReportExecution2005.asmx"
binding="basicHttpBinding" bindingConfiguration="ReportExecutionServiceSoap"
contract="MyApplicationService.ReportExecutionServiceSoap" name="basicHttpEndpoint" />
</client>
</system.serviceModel>
我做过的事情。
- 停止使用 using 关键字。.没有任何效果.
- 服务在我的浏览器上工作,所以怎么会出错。
- 尝试过 .Net 跟踪没有得到任何帮助,因为错误消息保持不变。
- 尝试使用WCFTestClient.exe也存在数据,但是通过客户端编写代码,它给了我错误。
- 状态有时是 Opened, Mostly faulted,但通过快速监视写入的端点显示其 null,如下图所示。但是我在 URL 地址中得到了一些东西。
有人可以指导我吗?我被困在这里好几个星期了。
答: 暂无答案
评论