November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Note: This topic has no later version.
NOTE: The XML Web Services extensions described in this article are based on the legacy ASP.NET 2.0 Web Services Technology. These extensions are shipped with EPiServer CMS up to version 7.5 but is not available in later versions. We recommend using either the Service API to integrate with external systems or Windows Communication Foundation (WCF) to create your own custom XML Web Services.
The EPiServer CMS sample site installation includes the following web services ready for use:
You need to install the episerver webservices module by installing "Install EPiServer Web Services" from EPiServer Deployment Center. After installing of the module a WebServices directory would be copied under applications path. This directory is protected in the web.config file as follows:
<location path="WebServices">
<!--
Configure the EPiServer.Security.BasicAuthentication module to send a basic authentication challenge
instead of a redirect to the forms login page. For this to take effect the EPiServer.Security.BasicAuthentication
module must be added to the list of http modules.
-->
<system.web>
<httpRuntime maxRequestLength="1000000" />
<authorization>
<allow roles="WebServices,Administrators" />
<deny users="*" />
</authorization>
</system.web>
...
</location>
EPiServer CMS is installed with forms authentication by default. Web service clients cannot communicate with a web service that uses forms authentication, as the authentication occurs through an HTML user interface meant for visitors on the website. You must use Integrated Windows authentication, or follow the steps in the section Configuring EPiServer CMS to Enable Basic Authentication below, to emulate Basic authentication if you want to use both forms authentication and web services on the same site.
Web services cannot authenticate against a forms-authenticated site, because the forms authentication login window requires user interaction. This section describes how to configure and set up EPiServer CMS to enable basic authentication, normally only supported when using Windows authentication, on parts of the website.
The BasicAuthentication http module will translate basic authentication requests on-the-fly to forms-authenticated cookies. Make sure to define the BasicAuthentication filter under the <system.webserver><modules> section section in web.config as follows:
<system.webServer>
<modules ...>
<add name="BasicAuthentication" type="EPiServer.Security.BasicAuthentication, EPiServer" />
<!-- Other modules -->
</modules>
</system.webServer>
Configure the EPiServer BasicAuthentication module disable the authentication challenge on the root folder by adding the following configuration:
<episerver.basicAuthentication sendBasicChallenge="false" basicRealm="" />
Then configure the EPiServer BasicAuthentication module to send an authentication challenge for the WebServices folder by adding the following configuration to the WebServices location section in web.config:
<location path="WebServices">
<episerver.basicAuthentication sendBasicChallenge="true" basicRealm="" />
The episerver.basicAuthentication configuration section should be declared in configSections like:
<section name="episerver.basicAuthentication" type="EPiServer.Configuration.BasicAuthenticationSection, EPiServer.Configuration" />
If you are using a windows account for authentication you have to make sure that the web service account is allowed access to the WebServices folder.
<location path="WebServices">
<system.web>
<authorization>
<allow roles="Administrators, WebServices" />
<deny users="*" />
</authorization>
</system.web>
</location>
Ensure that the integrated and basic authentication is disabled in IIS.
Verify that the user account used for authentication has access to the webservices folder.
Verify that you have made all necessary configuration settings for authentication under Step 3.
If you create your own web services, place them in the /WebServices folder to have the same security settings as the built-in web services. This is especially important, if you need to use forms authentication on your site. All the information you can access through the EPiServer API can also be exposed through web services.
The following web service makes all EPiServer CMS configuration settings available for external clients:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Xml;
using System.Text;
using System.IO;
using EPiServer;
using EPiServer.Core;
namespace development.
{
/// <summary>
/// Utility members for EPiServer
/// </summary>
[WebService(Namespace=<a href="http://episerver.com/episerversample/webservices/">http://episerver.com/episerversample/webservices/</a>,
Description="Utility functions for EPiServer, giving you information about the site.")]
public class EPiServerUtil : System.Web.Services.
{
[WebMethod(Description="Returns the servers time according to DateTime.Now()")]
public DateTime ServerTime()
{
return DateTime.Now;
}
[WebMethod(Description="Returns all configuration settings for this site as XML.")]
public string ConfigurationXml()
{
System.Collections.Specialized.NameValueCollection oSettings;
StringBuilder oBuilder = new StringBuilder();
StringWriter oTextWriter = new StringWriter(oBuilder);
XmlTextWriter writer = new XmlTextWriter(oTextWriter);
// Build the XML
writer.WriteStartDocument();
writer.WriteStartElement("episerverconfig");
writer.WriteAttributeString("version", Global.EPConfig.Version );
writer.WriteStartElement("values");
oSettings = Global.EPConfig.ConfigFile.AllAppSettings;
for (int i = 0; i < oSettings.Count; i++)
{
writer.WriteStartElement("value");
string[] keyvalue = oSettings.GetValues(i);
writer.WriteElementString("key", oSettings.Keys[i]);
writer.WriteElementString("value", string.Join(",", keyvalue));
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
oTextWriter.Close();
return oBuilder.ToString();
}
public EPiServerUtil()
{
//CODEGEN: This call is required by the ASP.NET Web Services Designer
InitializeComponent();
}
//Required by the Web Services Designer
private IContainer components = null;
private void InitializeComponent()
{
}
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
}
}
var client = new MyServiceReference.MyServiceSoapClient();
client.ClientCredentials.UserName.UserName = "user";
client.ClientCredentials.UserName.Password = "password";
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
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, instead of using the default behavior that relies on connection keep-alive and access-denied round-trips.
The main reason is that if the client and server are using connection keep-alive without storing cookies, the BasicAuthentication filter may not be able to capture subsequent requests that reuse a previously authenticated connection.
Last updated: Mar 31, 2014