Microsoft Office Tutorials and References
In Depth Information
Chapter 14: Building Custom Solutions
3.
In the Project Types frame, expand the Visual C# node and select Windows. In the Templates
frame, select Console Application.
4.
In the Name field, enter xlWebService .
5.
Set the Location field to the location where you want to create the solution.
6.
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
xlWebService.
Adding the API Web Reference
Follow these steps to add the API Web reference.
1.
Select Project
Add Web Reference to open the Add Web Reference dialog box.
2.
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.
3.
Click Go to retrieve the available web service. The service appears in the list as ExcelService.
4.
In the Web Reference Name field, enter ExcelWebService .
5.
Click the Add Reference button to add the ExcelService web service as a web reference to the
solution.
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
statement:
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