newHelpline: +91-22-26201604 Ext.633/607.
Mobile Seva

Java Client for accessing Mobile Seva IVRS Push Call API ?

Note: IVRS Push Call API will be accessible with TLSv1.2 protocol. Kindly upgrade to latest Java versions for TLSv1.2 support.

Java Version TLS Protocol Supported
Java 7 Supports TLSv1.2. But by default TLS1.0 is used. So, kindly specify TLSv1.2 in code.
Java 8 & above Supports TLSv1.2. By default TLSv1.2 is used.

Steps to import certificate in Java Keystore required for JAVA version 7

1) Click to download the webservice certificate(Size:1,950B)
Note: Import the certificate into the Java Store if you are using JAVA version 7.
2) Make sure you have write access to your JRE and use the keytool utility to import it:
keytool -import -alias alias -keystore path-to-jre/lib/security/cacerts -file path-to-certificate-file
keytool -import -alias sunas -keystore /opt/jdk1.7/jre/lib/security/cacerts -file /home/gugrim/tmp/msdgwebmgov.crt
3) You will be prompted for the keystore password, which is by default changeit.
4) Also, when you connect to the server make sure you use the same name as the one set as the Subject in the certificate. You may need to add it to your host file if the server isn't reachable using this name, which may be the case for a development/production server.

Note: No need to import certificate for java version 8 and above

Click to download the Java code file(Size:3KB)
Click to download the Required Jars for below code(Size:2.5MB)
package in.cdac;

import java.util.ArrayList;
import java.util.List;


import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.ssl.SSLContexts;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

public class IVRSPushCall {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String userName="";//Your username of services portal 
		String password="";//Your Password 	
		String mobileNumber="";//If more than 1 then seprated by comma(,)
		String voiceCode="";//as uploaded on website( give only nuber of voicecode)
	private static void makePushCall( String userName,String password,String mobileNumbers,String voiceCode){
		SSLSocketFactory sf=null;
		SSLContext context=null;
		try {
			context=SSLContext.getInstance("TLSv1.2"); //This line is required only for Java 7. No need for java 8 and above.
			context.init(null, null, null);
			sf=new SSLSocketFactory(context, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
			Scheme scheme=new Scheme("https",443,sf);
			HttpClient client=new DefaultHttpClient();
			HttpPost post=new HttpPost("");
			List nameValuePairs=new ArrayList(1);
			nameValuePairs.add(new BasicNameValuePair("username", userName));
			nameValuePairs.add(new BasicNameValuePair("password", password));
			nameValuePairs.add(new BasicNameValuePair("MobileNumbers", mobileNumbers));
			nameValuePairs.add(new BasicNameValuePair("voiceCode", voiceCode));
			post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
			HttpResponse response=client.execute(post);
			BufferedReader bf=new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
			String line="";
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
		} catch (KeyManagementException e) {
			// TODO Auto-generated catch block
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block
		} catch (IOException e) {
			// TODO Auto-generated catch block