问题描述
我正在做一个控制台应用程序,它会告诉 EpiServer web 服务添加一个页面.我的问题是我无法进行身份验证.我在 Epi 后台创建了一个网络服务用户.我可以使用我的帐户通过浏览器登录网络服务.
I'm doing a console applications that will tell the EpiServer webservice to add a page. My problem is that I can't get the autentication to work. I've created a webservice user in Epi backofice. I can login to the webservice through the browser with my account.
控制台应用的代码示例如下.
A code sample from the console app is as follows.
var client2 = new ContentChannel.ContentChannelServiceSoapClient();
client2.ClientCredentials.UserName.UserName = "username";
client2.ClientCredentials.UserName.Password = "password";
client2.Open();
client2.ImportPage1(null, "Pagename", null, null, "sv", newGuid, parentGuid, "pagetype");
client2.Close();
我得到的错误信息是
System.Web.Services.Protocols.SoapException:服务器无法处理请求.---> EPiServer.Core.EPiServerException: 用户没有没有访问 Web 的Permission.WebServiceAccess"访问权限远程站点上的服务,用于用户EPiServer.WebServices.DataFactoryService.ValidateWebServiceAccess()
在EPiServer.WebServices.ContentChannelService.ValidateWebServiceAccess()在 EPiServer.WebServices.ContentChannelService.ImportPage(StringchannelId, String pageName, String[] propertyKeys, String[]属性值、字符串文化名称、Guid pageId、Guid parentPageId、String pageTypeName) --- 内部异常堆栈跟踪结束---
我不知道我是否需要在配置文件中显示我是如何完成的,但是如果我应该添加它,请告诉我.如果有人知道如何从这里走,请回答.提前致谢!
I don't know if I need to show how I've done in the config files but if I should add that, just tell me.If anyone know how to go from here, please answer.Thanks in advance!
编辑
我得到了一个名字的错误,我得到了登录提示,而不是表单身份验证,我可以使用一些网络服务方法,例如
I get the error with a name, I get the login prompt, not the forms authentication, I can use some webservice-methods, such as
ContentChannel.GetMaxRequestLength()
但是每当我尝试正确使用 Web 服务或调用 ValidateWebServiceAccess() 时都会收到此错误
but I get this error whenever I try to use the webservice properly or call the ValidateWebServiceAccess()
System.Web.Services.Protocols.SoapException: Server was unable to
process request. ---> EPiServer.Core.EPiServerException: The user does
not have the 'Permission.WebServiceAccess' access right to access web
services on the remote site, for user andreas
推荐答案
首先,请按照此链接设置和配置 Web 服务:http://world.episerver.com/Documentation/Items/Tech-Notes/EPiServer-CMS-6/EPiServer-CMS-60/Web-Services/
First of all, follow this link to setup and configure web service: http://world.episerver.com/Documentation/Items/Tech-Notes/EPiServer-CMS-6/EPiServer-CMS-60/Web-Services/
然后转到 EPIServer 管理模式,单击配置选项卡,然后单击安全子组中的功能权限,然后单击允许用户充当 Web 服务用户"附近的编辑.添加您的用户,点击保存.
Then go to EPIServer admin mode, click Config tab, then Permissions for Functions in Security subgroup, and click Edit near "Allow the user to act as a web service user". Add your user, click Save.
然后打开IE,打开你本地的url http:///WebServices/ContentChannelService.asmx
After that open IE, and open your local url http://<yourlocalsite>/WebServices/ContentChannelService.asmx
确保您没有被重定向到登录屏幕,而是收到浏览器登录/密码弹出窗口.尝试使用您的网络服务用户登录.
Ensure you are not redirected to Login screen, but receive browser login/pass popup. Try login with your webservice user.
还要确保在您的代码中完成此操作:
Also ensure this is done in your code:
当使用 .NET soap 客户端与 EPiServer CMS 通信时,将属性 SoapHttpClientProtocol.PreAuthenticate 设置为 true 以确保在每次请求时都将用户名和密码发送到服务器
这篇关于EpiServer Web 服务 6.0,使用 Web 服务时出现身份验证问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!