微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

WCF 服务 SSRS 在我的浏览器上通过 URL 工作,但在 WCF 客户端上不起作用?

如何解决WCF 服务 SSRS 在我的浏览器上通过 URL 工作,但在 WCF 客户端上不起作用?

在使用用户名和密码进行 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,parameters,out executionInfo);

                // Render
                serverInfoHeader =
                    webServiceProxy.Render(executionHeader,GetExportFormatString(format),out streamIds);
                webServiceProxy.Close();
            }
            catch (CommunicationException e)
            {

                webServiceProxy.Abort();
                throw new CommunicationException(e.Message);


            }
            finally
            {
                webServiceProxy.Close();

            }

网络配置文件

    <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>

为了更多说明,这里是附有错误消息的图片

enter image description here

我做过的事情。

  1. 停止使用 using 关键字.. // 没有任何效果
  2. 服务正在我的浏览器上运行,怎么会出现故障。
  3. 尝试过 .Net Tracing 没有得到任何帮助,因为错误消息保持不变。
  4. 尝试使用 WCFTestClient.exe 也有数据,但通过客户端编写代码,它给了我错误
  5. 状态有时是打开的,大部分是错误的,但通过快速观察写入的端点显示为空,如下图所示。但是我在 URL 地址中得到了一些信息。

有人可以指导我吗?我被困在这里好几个星期了。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。