The MOSS ExcelServices provides the web service which can be easily integrated in any .NET base client application. The URI of the ExcelServices is in general: http://yourmosshost/_vti_bin/excelservice.asmx./ As you see it is obvious that the ExcelServices Web Service is based on the ASP.NET web service technology. However if you want ro invoke this service from the client which is based on WCF you may run in several problems.
Following two error messages are most common while trying to connect:
Server was unable to process request. ---> A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - Either a required impersonation level was not provided, or the provided impersonation level is invalid.)
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.
To workaround this problem do following:
- Add service reference to the ExcelServices URI shown above.
- Change the security settings of the automatically imported Endpoint in the app. configuration file. (see below)
- Use the code shown below.
Following configuration change enforces Windows Authentication:
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
Following example shows how to get the value of one cell:
ExcelServiceSoapClient client = new ExcelServiceSoapClient();
client.ClientCredentials.Windows.AllowedImpersonationLevel =
System.Security.Principal.TokenImpersonationLevel.Impersonation;
Status[] status;
string sessionId =
client.OpenWorkbook("http://yourmosshost/SomeExcelFile.xlsx",
"en-US", "en-US", out status);
object res = client.GetCell(sessionId,
"Sheet1", 1, 1, true,
out status);
Posted
Nov 17 2007, 07:55 PM
by
Damir Dobric