Webservice to SIP Phone Call through RESTCOMM

259 views
Skip to first unread message

vixmemon

unread,
Mar 7, 2013, 9:51:10 AM3/7/13
to mobicent...@googlegroups.com
Maybe i am too lost in configuration and reads that i cant figure out how must i start with this.. 

I want a webservice to initiate a call from RestComm to a SIP Phone. The call should be automatic and should play a playback along with DTMF input. 

Is it possible?

Ivelin Ivanov

unread,
Mar 7, 2013, 12:38:33 PM3/7/13
to mobicent...@googlegroups.com
This is one of the most typical scenarios. 

Point taken about ease of configuration. Feel free to write a blog post how you made it work and what you would recommend as improvements.

Do you have Java dev background or you are running on a different language platform?

Ivelin



--
You received this message because you are subscribed to the Google Groups "mobicents-public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobicents-publ...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Thomas Quintana

unread,
Mar 7, 2013, 1:32:46 PM3/7/13
to mobicent...@googlegroups.com
Yes it is, please refer to my response on your other email to the subject.

Best Regards,
Thomas

vixmemon

unread,
Mar 7, 2013, 4:48:40 PM3/7/13
to mobicent...@googlegroups.com
yes, 

I am trying to do it with Java. I believe i can use RestComm Java wrapper for this. 
So, 
for this i need to do following i guess?

1. Register 2 users through REST API (curl)?
2. Use Rest API to call from 1 user to other?
3. Use Java Wrapper for RestComm?

vixmemon

unread,
Mar 9, 2013, 2:53:28 AM3/9/13
to mobicent...@googlegroups.com
It didnt help. 

I need a small/simple example or a way out. 

I want to be able to call a SIP URI through my Java Application running on top of RestComm and Mobicents. I dont want to use a softphone to call a softphone, i want to use Java Wrapper/API/REST API to call a softphone, play an audio and receive DTMF inputs. 

Thomas Quintana

unread,
Mar 9, 2013, 8:42:43 AM3/9/13
to mobicent...@googlegroups.com
Hi,

Below is an example of how to make an outbound call from RestComm using the Java wrapper.

Best Regards,
Thomas

        // Set the call parameters.
final Account account = client.getAccount();
final Map<String, String> parameters = new HashMap<String, String>();
parameters.put("From", "+12223334444");
parameters.put("To", "+17778889999");
parameters.put("Method", "POST");
parameters.put("Timeout", "30");
try {
 // Make the phone call.
 final Call call = account.getCallFactory().create(parameters);
} catch(final TwilioRestException exception) {
 logger.error(exception);

vixmemon

unread,
Mar 9, 2013, 6:28:45 PM3/9/13
to mobicent...@googlegroups.com
I have not yet tried this example. I will try it as soon as i m on my dev machine. 
Just curious to know, 
Which account will this client.getAccount() return?

Can i get a list of SIP users connected with my RCML application? 

vixmemon

unread,
Mar 11, 2013, 8:29:31 AM3/11/13
to mobicent...@googlegroups.com
I am trying this example with Click2Call. I have 2 sip phone users registered with click2call, and i have this main method which should call from 1 sip uri to other..


public static void main(String[] args) {
        //I have replaces accountSID and AUTHTOKEN with my accountsid and authtoken for twilio...
        TwilioRestClient client = new TwilioRestClient(ACCOUNTSID, AUTHTOKEN);

       
         // Set the call parameters.
        final Account account = client.getAccount();
        final Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("From", "ser...@127.0.0.1:5080");
        parameters.put("To", "us...@127.0.0.1:5080");

        parameters.put("Url",  "http://127.0.0.1:8080/restcomm/demo/hello-world.xml");
        parameters.put("Method", "POST");
        parameters.put("Timeout", "30");
        parameters.put("Endpoint", "http://127.0.0.1:8080/restcomm"); // i have tried with this and without this....

        try {
          // Make the phone call.
          final Call call = account.getCallFactory().create(parameters);
       
        } catch(final TwilioRestException exception) {
            System.err.println(exception.getMessage());
            exception.printStackTrace();
        }

    }

but, i get following exception
Exception in thread "main" java.lang.UnsupportedOperationException: text/html;charset=utf-8 not a supported content type
    at com.twilio.sdk.TwilioRestResponse.getParser(TwilioRestResponse.java:230)
    at com.twilio.sdk.TwilioRestResponse.toMap(TwilioRestResponse.java:243)
    at com.twilio.sdk.TwilioRestException.parseResponse(TwilioRestException.java:58)
    at com.twilio.sdk.TwilioRestClient.safeRequest(TwilioRestClient.java:522)
    at com.twilio.sdk.resource.list.CallList.create(CallList.java:68)
    at com.systems.Main.main(Main.java:61)

vixmemon

unread,
Mar 12, 2013, 3:07:53 AM3/12/13
to mobicent...@googlegroups.com
Here is the deal, 

     public TwilioRestResponse(String url, String text, int status) {
Pattern p = Pattern.compile("([^?]+)\\??(.*)");
Matcher m = p.matcher(url);
m.matches();
this.url = m.group(1);
this.queryString = m.group(2);
this.responseText = text;
this.httpStatus = status;
this.error = (status >= 400);
}

in this method, i get following values. 


this.queryString = "";
this.responseText = "<h1>HTTP Status 401 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>This request requires HTTP authentication ().</u></p>";
this.httpStatus = 401;
this.error = true;

vixmemon

unread,
Mar 12, 2013, 5:05:13 AM3/12/13
to mobicent...@googlegroups.com
Can I make a call to a SIP URI Instead?


I have Registered a Client like this


curl --data "Login=1234&Password=1234&VoiceUrl=http://127.0.0.1:8080/restcomm/demo/restcomm_dtmf_demo.xml&VoiceMethod=POST" http://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f842...@127.0.0.1:8080/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Clients.json

Then, I registered a SIP Soft Phone with this User name... the sip phone is running with this registered user. 

now, i need to make a call to this SIP Phone. 

        final TwilioRestClient client = new TwilioRestClient("ACae6e420f425248d6a26948c17a9e2acf", "77f8c12cc7b8f8423e5c38b035249166");
        final Account account = client.getAccount();
        final CallFactory factory = account.getCallFactory();
        final Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("To", "sip:12...@127.0.0.1:5080");
        parameters.put("From", "sip:15...@127.0.0.1:5080");
        parameters.put("Url", "http://127.0.0.1:8080/restcomm/demo/hello-world.xml");
        final Call call = factory.create(parameters);
        call.hangup();

I get following exception

org.codehaus.jackson.JsonParseException: Unexpected character ('E' (code 69)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
 at [Source: java.io.StringReader@100e1b3c; line: 1, column: 2]
at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1432)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:442)
at org.codehaus.jackson.impl.ReaderBasedParser._handleUnexpectedValue(ReaderBasedParser.java:1198)
at org.codehaus.jackson.impl.ReaderBasedParser.nextToken(ReaderBasedParser.java:485)
at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2763)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2711)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1856)
at com.twilio.sdk.parser.JsonResponseParser.parseJson(JsonResponseParser.java:33)
at com.twilio.sdk.parser.JsonResponseParser.parse(JsonResponseParser.java:19)
at com.twilio.sdk.TwilioRestResponse.toMap(TwilioRestResponse.java:244)
at com.twilio.sdk.TwilioRestException.parseResponse(TwilioRestException.java:58)
at com.twilio.sdk.TwilioRestClient.safeRequest(TwilioRestClient.java:522)
at com.twilio.sdk.resource.list.CallList.create(CallList.java:68)
at com.systems.outbound.Main.testSayVerb(Main.java:76)
at com.systems.outbound.Main.main(Main.java:82)
Exception in thread "main" com.twilio.sdk.TwilioRestException
at com.twilio.sdk.TwilioRestException.parseResponse(TwilioRestException.java:74)
at com.twilio.sdk.TwilioRestClient.safeRequest(TwilioRestClient.java:522)
at com.twilio.sdk.resource.list.CallList.create(CallList.java:68)
at com.systems.outbound.Main.testSayVerb(Main.java:76)
at com.systems.outbound.Main.main(Main.java:82)

-----------------

TwilioRestResponse gives this Response Body.. 
Error type: NOT_A_NUMBER. The string supplied did not seem to be a phone number.







On Saturday, 9 March 2013 18:42:43 UTC+5, Thomas Quintana wrote:

vixmemon

unread,
Mar 13, 2013, 2:55:05 AM3/13/13
to mobicent...@googlegroups.com
Thomas, 

Can you tell me about the numbers in From and To? Can we somehow use our SIP URI registered with our RCML Application i.e. in case of DTMF demo, i have 2 number registered. I register a sip phone with my application and want to receive a call there.. 


On Saturday, 9 March 2013 18:42:43 UTC+5, Thomas Quintana wrote:
Reply all
Reply to author
Forward
0 new messages