Try our conversational search powered by Generative AI!

Consuming EPiServer Web Services from code - Authentication Problem


I am trying to consume the PageStoreService.asmx webserices from code using the tech note

I have successfully enabled basic authentication and can browse the services through a web browser and invoke them.

I can add a web service reference to the asmx file in my visual studio project (.NET 4.0 Web application) but when I come to create an instance of the proxy object (in my instance, its named PageServiceStoreSoapClient) there are no .Credentials or .PreAuthenticate attributes for me to set for the authentication.

Looking at the generated code for the object, it inherits System.ServiceModel.ClientBase<PageStoreServiceSoap>.

This is likely more of a dot net question than specifically EPiServer. 

Can anyone help? has anyone had the same issue before?

Many Thanks,



May 22, 2012 16:03

So it seems the code example from the tech note relates to how you consume this in a .NET 2.0 application - when using .NET 4.0, the classes are gerneated using the WCF way. To correctly enable this two things have to be done differnetly.

1. The username and password can still be changed via code but through the .ClientCredentials Property of the soap client class. Example:

var client = new MyServiceReference.MyServiceSoapClient();
client.ClientCredentials.UserName.UserName = "user"; 
client.ClientCredentials.UserName.Password = "password";    

2. The security mode needs changing from this (the default setup when adding the web refernece in .config file)

<security mode="None">
  <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
  <message clientCredentialType="UserName" algorithmSuite="Default" />

To this:
<security mode="TransportCredentialOnly">
  <transport clientCredentialType="Basic" />
In terms of the pre-authenticate (detailed in the tech note) Im not sure how that works in the 'WCF' way, but the above works successfully.


Edited, May 23, 2012 13:20


I'm trying to do the same thing but I always get the following error not matter what I try, even if the credentials are set on the proxy, my security binding changed and my user is created in the CMS admin with webservice permission checked. What Am I missing ?

EPiServer.Core.EPiServerException: The user does not have the 'Permission.WebServiceAccess' access right to access web services, for user 


Aug 07, 2012 20:50

Have you given the user access to the web services "Allow the user to act as a web service user" in the "Permissions to functions" (Admin > Config > Security)?

Aug 08, 2012 9:54

Yes. I tried many things but I didn't worked. I launched fiddler to try to figure out the problem and I don't know why but after the 1st call to the webservice (that return a 401 status, as expected), I send back the credentials for the user (crendentials are good, user is in a group that is allowed to be used as a web service user), the webservices location authorization are set properly in my web.config and even then, I still get a 401 status on the second call instead of a 200. I tried with another instance of EpiServer we have with the same client code and it works without problems. 


Aug 08, 2012 14:36
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.