Steps to Call an iService Method |
This topic contains the following sections.
- Creating an Instance of an iService
- Add a Method to Generate the Username Token Information
- Generating the Username Token Information
- Associating the Username Token with the iServices Instance
- Setting the URL of the Web Service
- Calling a Method of an iService
- Complete Code Sample for the CreateContact Method in the Contact iService
This section provides information to call an iService method.

To call a method of a specific iService, you must first write the code to create an instance of the iService in the main project.
For example, to call a method of the Contact iService, you must write the following code to create an instance of the Contact iService:
ContactWebService ContactService = new ContactWebService();
In the above code snippet:
-
ContactWebService is the name of the Web Service class of the Contact iService.
-
ContactService is the instance name for the Contact iService.

You can use the following method to generate Username Token information. The User token information is used to authenticate the user during the iService calls.
public UsernameToken getUserToken(string userName, string password) { UsernameToken userToken = new UsernameToken(userName, password, PasswordOption.SendPlainText); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlElement TalismaSession = doc.CreateElement("TalismaSessionkey"); TalismaSession.InnerText = ""; //Pass this values as blank if no session has to be mantained. userToken.AnyElements.Add(TalismaSession); return userToken; }
In the above code snippet:
-
userToken stores the login credentials of the user that will be used during the iServices call.
-
userName and password are credentials used during the iServices call.
-
TalismaSessionKey is the Session key used to authenticate the user every time the iService method is called. Pass this value as blank, if no session has to be maintained.
![]() |
---|
This method is used in the samples provided in the Code Samples section. |

Add the following line of code to obtain the Username token used for iService calls.
UsernameToken userToken = getUserToken("ParkerRoy", "password");
In the above code snippet:
-
ParkerRoy is the username of the user that will be used to make the iServices call.
-
Password is the password of the user ParkerRoy.

Add the following line of code to associate the Username token with the iServices instance:
ContactService.RequestSoapContext.Security.Tokens.Add(userToken);
ContactService.RequireMtom = false;

Add the following line of code if you are using an iService URL that is different from the one that was added while adding the Web Reference for the iService.
ContactWebService.Url = "http://worldwaves/ContactiService/Contact.asmx";
In the above code snippet:
-
http://worldwaves/ContactiService/Contact.asmx is the URL of the Contact iService available on the computer where iServices is installed.

Following is a sample code to call the CreateContact method of the Contact iService to create a Contact with the name Sam and e-mail address Sam@gmail.com.
long contactID = -1; string error = ""; string contactName = "Sam"; bool updateReadOnly = false; bool bIgnoreMandatory = false; long result = 0; //Create a Collection for 2 Contact Properties, Name and E-mail, to create a Contact in CampusNexus CRM. ContactiService.PropertyInfo[] propertyDataCollection = new ContactiService.PropertyInfo[2]; //Create the PropertyInfo for the Name Property of the Contact Object ContactiService.PropertyInfo namePropertyData = new ContactiService.PropertyInfo(); namePropertyData.propertyID = 56; //Here, 56 is the Property ID for the Name Property of the Contact Object. namePropertyData.propValue = "Sam"; propertyDataCollection[0] = namePropertyData; //Create the PropertyInfo for the E-mail Property of the Contact Object ContactiService.PropertyInfo emailPropertyData = new ContactiService.PropertyInfo(); emailPropertyData.propertyID = 57;//Here, 57 is the Property ID for the E-mail Property of the Contact Object. emailPropertyData.propValue = "Sam@gmail.com"; propertyDataCollection[1] = emailPropertyData; result = ContactService.CreateContact(contactName, propertyDataCollection, updateReadOnly, bIgnoreMandatory, out contactID, out error);

public void CreateContactSample() { //Creating an Instance of the Talisma CRM Contact iService ContactWebService ContactService = new ContactWebService(); //Generating the UsernameToken UsernameToken userToken = getUserToken("ParkerRoy", "Password"); //Associating the Username Token with the Contact iService Instance ContactService.RequestSoapContext.Security.Tokens.Add(userToken); ContactService.RequireMtom = false; //Calling the CreateContact Method of Talisma CRM Contact iService long contactID = -1; string error = ""; string contactName = "Sam"; bool updateReadOnly = false; bool bIgnoreMandatory = false; long result = 0; //Create Collection for 2 Properties, Name and E-mail will be used to create the contact. ContactiService.PropertyInfo[] propertyDataCollection = new ContactiService.PropertyInfo[2]; //Create the PropertyInfo for Contact Name Property ContactiService.PropertyInfo namePropertyData = new ContactiService.PropertyInfo(); namePropertyData.propertyID = 56; //Here, 56 is the Property ID for the Name Property of the Contact Object. namePropertyData.propValue = "Sam"; propertyDataCollection[0] = namePropertyData; //Create the PropertyInfo for Contact E-mail Property ContactiService.PropertyInfo emailPropertyData = new ContactiService.PropertyInfo(); emailPropertyData.propertyID = 57;//Here, 57 is the Property ID for the E-mail Property of the Contact Object. emailPropertyData.propValue = "Sam@gmail.com"; propertyDataCollection[1] = emailPropertyData; result = ContactService.CreateContact(contactName, propertyDataCollection, updateReadOnly, bIgnoreMandatory, out contactID, out error); }