Make and receive VoIP phone calls through HTTP requests using your Java application

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

Make and receive VoIP phone calls through HTTP requests using your Java application

Hello Everyone,

I'm working on a huge VoIP telephony project using Java and HTTP and I learned something cool today that I think would be useful for you. Let me share my project in the hope that I can help anyone who wants to improve her/his communication system Ė and I also hope you will contribute to my solution by providing any further useful development suggestion.

Introduction to the problem

It was often such that I needed a separate application to be able to manage my telephone system. The most common case: I was on a conference, but I suddenly needed to notify my colleagues related to some issue. Since I couldnít start a phone conversation there, I could rely on my laptop solely. However, most of my colleagues are usually out of the office, so the only way for reaching them immediately is a phone call or an SMS. Instead of typing and sending dozens of SMSs, I thought it would be more effective (and more personal) to use an application that allows me to make phone calls and plays a specified message.

Background of development

Concerning to the fact that HTTP requests and responses can be used for this purpose, I started to build a HTTP-based solution. The following figure illustrates how it works:

As Iím a passionate Java developer, I used this programming language. For implementing my VoIP telephony solution I have used the HTTP API provided by Ozeki Phone System along with NetBeans. The Java Development Kit (JDK) is essentially needed, so if you install the NetBeans IDE, please install the JDK as well (see below). To be able to make (and receive) phone calls, a softphone is also required. Therefore I downloaded and installed CounterPath X-Lite softphone.

Code explanation

Having done with the introduction section, Iím going to explain what you need to do if you are interested in my solution.

After you have installed all the necessary software, you need to start a new Java project in NetBeans (or Eclipse, or any other Java IDE). For this purpose, in NetBeans, click on File then select the New Project menu item.

To make my project complete, I will present two-way communication. That is, I will not explain only how to make a phone but also how to receive a phone call by using your Java application.

First of all you need to select which port receives the incoming calls. For this purpose, click on the Productivity menu item in the Ozeki PBX then choose the HTTP API item from the dropdown menu. Here, you need to add a new API extension notification, then you can set the address of incoming calls by using the URL field of Incoming call. In this example, this is the 7778 port of localhost. Now, make a Java application that checks this port and gives a HTTP response if a call arrives.

Make a ServerSocket object and add the port number in its constuctor. You can accept an incoming request by calling the accept() method. After the invitation, you will get back a Socket object. Call the getOutputStream method of socket, in order to give a response back. This leads to an OutputStream. You can send back the appropriate response through this by calling the write method of outputstream. It waits for a byte array. As a result the String typed response message needs to be converted to a byte typed array. You can manage to do it if you use the getBytes method(). Finally, with the help of the outputStream flush() method, you can send the answer.

To make an outgoing call, make a sample by a URL class. Then connect to the URL, which was given in the construstor of the URL object. To do this, invite the openConnection() method of the object which sends back an URLConnection typed object. Then convert it to HttpURLConnection format. In this file, set the method of the request and send it, using the connect() method.

Iím thinking srongly about some additional enhancements, such as call recording to be able to record an important one calling. Do you have any idea regarding with my VoIP application?

Conclusion

To sum it up I have created a really simple application that can be used to make and receive phone calls through your VoIP network by using your Java program. I have implemented this solution using HTTP requests and responses.

References and the availability of programs used

If you want to try out my solution, you may need some software. The following collection contains all the necessary application and information you need to know.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.