wcf – .Net Core ReportExecutionServiceSoapClient设置凭据
我在.Net Core中使用ReportExecutionServiceSoapClient我得到了.net Core的最新版本,并尝试从报告服务中获取报告.在我使用WCF连接服务之后,我能够添加看起来像下面的代码
// Instantiate the Soap client ReportExecutionServiceSoap rsExec = new ReportExecutionServiceSoapClient(ReportExecutionServiceSoapClient.EndpointConfiguration.ReportExecutionServiceSoap); // Create a network credential object with the appropriate username and password used // to access the SSRS web service string historyID = null; TrustedUserHeader trustedUserHeader = new TrustedUserHeader(); ExecutionHeader execHeader = new ExecutionHeader(); // Here we call the async LoadReport() method using the "await" keyword,which means any code below this method // will not execute until the result from the LoadReportAsync task is returned var taskLoadReport = rsExec.LoadReportAsync(reportPath,historyID); // By the time the LoadReportAsync task is returned successfully,its "executionInfo" property // would have already been populated. Now the remaining code in this main thread will resume executing string deviceInfo = null; string format = "EXCEL"; // Now,similar to the above task,we will call the RenderAsync() method and await its result var taskRender = await rsExec.RenderAsync(renderReq); 当它的组织renderAsync全部崩溃,因为服务的凭证没有在任何地方设置.我试图登录异步没有成功.此外,我尝试使用SetExecutionCredentialsAsync设置凭据,但我得到并且错误地说“HTTP请求未经授权使用客户端身份验证方案’匿名’.从服务器收到的身份验证标头是’NTLM’.”我不知道如何为ReportExecutionServiceSoapClient更改它. 我已经阅读了一些帖子,其中微软的人说用肥皂的身份验证没有解决,但对我来说似乎是如此接近真实.我觉得我错过了什么. 技术堆栈:VS 2017,.net核心web api,ssrs 2016,sql server 2016标准 如何对此呼叫的用户进行身份验证? 解决方法
我知道这是一个古老的问题,但我有同样的问题,偶然发现了答案.
创建ReportExecutionServiceSoap对象后,您可以在ClientCredentials中指定用户名和密码.我使用Basic客户端凭证类型获得了成功.请确保您使用的是HTTPS,否则您的密码将以明文形式发送到报告服务器.我还建议将用户/密码存储在安全的地方而不是代码. BasicHttpBinding rsBinding = new BasicHttpBinding(); rsBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; rsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; EndpointAddress rsEndpointAddress = new EndpointAddress("https://servername/ReportServer/ReportExecution2005.asmx"); var rsExec = new ReportExecutionServiceSoapClient(rsBinding,rsEndpointAddress); rsExec.ClientCredentials.UserName.UserName = "username"; rsExec.ClientCredentials.UserName.Password = "pass"; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 使用C#通过Oracle.DataAccess连接Oracle,部署时需要注意版
- asp.net – .NET接口签名
- asp.net-mvc – 从DataAnnotation类中渲染LabelFor无标签标
- asp.net – Mscaptcha在本地运行良好,但图片没有在服务器中
- asp.net – 如何在Azure网站上设置machineKey
- asp.net-mvc-3 – 我可以传递视图模型到动作链接来生成路由
- asp.net – 链接按钮属性在新选项卡中打开?
- 在当前的HTTPContext中生成一个新的ASP.NET会话
- .net – 带标准短语的免费/开源resx文件
- ASP.NET与IIS VS PHP与Apache
- asp.net-mvc – 使用Checkboxes绑定到具有强类型
- asp.net-mvc-3 – 如何模拟httpcontext使单元测试
- asp.net-mvc – 在IIS6上使用jqGrid和ASP.NET MV
- OWIN上的CORS和访问/令牌导致“Access-Control-A
- asp.net-mvc-3 – 偶数和奇数表行与Razor
- mime-types – 在ASP.NET 5中使用MimeMapping(vN
- asp.net-core – aspnet核心应用程序中的Autofac
- asp.net – 更改后没有应用CSS
- .NET Core采用的全新配置系统[8]: 如何实现配置与
- asp.net – 通过不同的Web应用程序共享相同的dll