Invoking of ExcelServices within WCF

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

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:

  1. Add service reference to the ExcelServices URI shown above.
  2. Change the security settings of the automatically imported Endpoint in the app. configuration file. (see below)
  3. 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
Filed under: , ,

Comments

Roy wrote re: Invoking of ExcelServices within WCF
on 04-01-2009 0:57

Using this same scenario, call Excel Services using WCF, how can we make the following call:

List<object> range = client.GetRange(sessionId, "sheet1", rc, false, out status);

where rc was defined as a new RangeCoordinates() class.

When I call GetRange, i get an XMLSerialization error where "ArrayOfAnyType" is unknown to the serializer.

What am I missing?

Thanks.

developers.de is a .Net Community Blog powered by daenet GmbH.