问题
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();
The error message I get is
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 at EPiServer.WebServices.DataFactoryService.ValidateWebServiceAccess()
at EPiServer.WebServices.ContentChannelService.ValidateWebServiceAccess() at EPiServer.WebServices.ContentChannelService.ImportPage(String channelId, String pageName, String[] propertyKeys, String[] propertyValues, String cultureName, Guid pageId, Guid parentPageId, String pageTypeName) --- End of inner exception stack trace ---
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!
EDIT
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()
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
回答1:
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/
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.
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:
When communicating with EPiServer CMS using a .NET soap client, set the property SoapHttpClientProtocol.PreAuthenticate to true to make sure that the username and password are sent to the server at every request
来源:https://stackoverflow.com/questions/15618120/episerver-web-service-6-0-problems-authenticating-when-using-webservice