If you want to use the APIs in the C# environment, you must perform certain steps to create a C# .NET client.
Consider the following before you setup the client for using the APIs:
Symantec recommends not to use multiple ISS API clients at the same time to avoid timeout erros.
When using APIs to retrieve bulk data, the default client configuration may not work. The API may return an error message as follows:
The maximum message size quota for incoming messages (65536) has been exceeded.
To increase the threshold, use the MaxReceivedMessageSize property on the appropriate binding element Increasing the maxmessagesize and receivetimeout as per the expected data-size, in the app.config.
To create a client in C# .NET
In Visual Studio, create a new project. Select the Windows project type and select the Console Applications template.
Right-click the newly created project in the Solution Explorer and click Add Service Reference.
Copy the URL for the service that you want to use in the Address field of the Add Service Reference dialog.
Refer the Syntax section of each API in the API Reference Guide for the URL.
The format of the URL is as follows for the TCP:
The format of the URL is as follows for the HTTPs:
Type the namespace name for service reference in the NameSpace textbox and click OK. For example: AssetService.
Click Yes in the Security Alert dialog. The security alert appears only in case you are using the https URL.
Add reference to the Service Reference that is added in step 4 in the code. For example: Using AssetService;
Copy the sample code for C# from the API Reference Guide for the API that you want to call and run the code.
All the code snippets that are provided with the APIs in the API Reference Guide are for the https://…../Basic/UserNameSecurity binding.
Let us understand the process of binding for the C# client with an example.
Consider you want to use the ISiteService to call one of the APIs.
You must follow the following steps in the given order for the C# client:
Initialize the client as follows:
SiteServiceClient client = new SiteServiceClient();
Use the code as follows depending on the binding and the mechanism you want to use to call the service:
Use the following with https//…../Basic/UserNameSecurity:
client.ClientCredentials.UserName.UserName = "E2EDOM\\Administrator";
client.ClientCredentials.UserName.Password = "password@123";
In this mechanism you must add the certificates to the certificate store on the client computer or you can add the following to the code to trust all the certificates:
System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender1, certificate, chain, sslPolicyErrors) => true);
Use the following with https//…../WS/WindowsSecurity:
client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
Use the following with https://…./WS/BasicUserNameSecurity
Use the following with http://…./WS/WindowsSecurity:
Enable the HTTP metadata from the Control Compliance Suite Console. To enable the HTTP metadata go to, Settings > Map View > Edit Settings > Integration Services > Http > Enable Metadata
Use the code below for delegation:
Call the API that belongs to the ISiteService as follows:
SiteIdentifier siteIdentifiers = client.GetAllSites();
Close the client as follows:
See Creating a client in Java
Subscribing will provide email updates when this Article is updated. Login is required to Subscribe
Thanks for your feedback. Let us know if you have additional comments below. (requires login)
This will clear the history and restart the chat.