Microsoft Office Tutorials and References
In Depth Information
Chapter 14: Building Custom Solutions
In the Project Types frame, expand the Visual C# node and select Windows. In the Templates
frame, select Console Application.
In the Name field, enter xlWebService .
Set the Location field to the location where you want to create the solution.
Select OK to create the application. The New Project dialog box closes and Visual Studio
opens the xlWebService solution with Program.cs opened and visible. The namespace is
Adding the API Web Reference
Follow these steps to add the API Web reference.
Select Project
Add Web Reference to open the Add Web Reference dialog box.
In the URL field, enter the URL to obtain the service description of the API. The URL should
be in the form of http://<wfe_server>/_vti_bin/ExcelService.asmx or http://
<wfe_server>/<site>/_vti_bin/ExcelService.asmx. This URL must support at least
View permissions.
Click Go to retrieve the available web service. The service appears in the list as ExcelService.
In the Web Reference Name field, enter ExcelWebService .
Click the Add Reference button to add the ExcelService web service as a web reference to the
Calling the API
Follow these steps to call the API:
1. In Program.cs, add a directive for the ExcelService web reference namespace. At the beginning
of Program.cs, add the following using statement:
using xlWebService.ExcelWebService;
2. Add a second directive to Program.cs for handling SOAP faults:
using System.Web.Services.Protocols;
3. In the Main(string[] args) method, instantiate, and initialize the API with the following
ExcelService xlEcsApi = new ExcelService();
4. Credentials must be explicitly set. Add the following statement to use default credentials:
xlEcsApi.Credentials = System.Net.CredentialCache.DefaultCredentials;
5. Create a status array and a string for the session ID:
Status[] xlStatus;
string xlSessionId = “”;
Search JabSto ::

Custom Search