Develop a new application that calls the REST interface.
Configure the location of the third-party web service WSDL.
Parent
Configure external web service providers to use CEA
Develop a new application that calls the REST interface.
Example
We can copy the following example code into an HTML file and preview it as part of a sample application. The code renders as a simple form where the user can enter two SIP URIs that represent two phones. When the Send XML button is pressed, the request is sent in XML format to the REST interface and a call is established. If the Send JSON button is pressed, the only difference is that the format of the request is JSON. The response is of the associated format and printed to a popup window. This example shows only one of the available REST interfaces.
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Call Tester</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <script type="text/javascript" language="javascript"> function setupXmlHttpRequest() { if( typeof XMLHttpRequest == "undefined" ) XMLHttpRequest = function() { try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {} try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {} try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {} try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {} throw new Error("This browser does not support XMLHttpRequest." ) }; } function createXML(addressOfRecord, peerAddressOfRecord) { var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; xml += "<CommRestRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "; xml += "xsi:noNamespaceSchemaLocation=\"CommServletSchema.xsd\">"; xml += "<enableCollaboration>false</enableCollaboration>"; if (addressOfRecord.length > 0) { xml += "<addressOfRecord>" + addressOfRecord + "</addressOfRecord>"; } if (peerAddressOfRecord.length > 0) { xml += "<peerAddressOfRecord>" + peerAddressOfRecord + "</peerAddressOfRecord>"; } xml += "</CommRestRequest>"; return xml; } function createJSON(addressOfRecord, peerAddressOfRecord) { var json = "{"; json += "enableCollaboration:false"; if (addressOfRecord.length > 0) { json += ",addressOfRecord:" + addressOfRecord; } if (peerAddressOfRecord.length > 0) { json += ",peerAddressOfRecord:" + peerAddressOfRecord; } json += "}"; return json; } function sendRequest(method, uri, caller, callee, json) { try { setupXmlHttpRequest(); var request = new XMLHttpRequest(); if (json == 1) { // Determine if there are parameters in the uri yet var paramChar = "&"; if (-1 == uri.indexOf('?')) { // No parameters. paramChar = "?"; } request.open(method, uri+paramChar+"JSON=true", false); request.send(createJSON(caller, callee)); } else { request.open(method, uri, false); request.send(createXML(caller, callee)); } alert(request.responseText); } catch (err) { alert(err.description); } } </script> </head> <body> <form name="myform"> <h2>Make Calls</h2> <p><hr> Caller Uri: <input type="text" name="caller_uri" value=""></input> Callee Uri: <input type="text" name="callee_uri" value=""></input> <input type="submit" onclick="sendRequest("PUT", "CommServlet/call", document.myform.caller_uri.value,document.myform.callee_uri.value,0)" value="Send XML"> <input type="submit" onclick="sendRequest("PUT", "CommServlet/call", document.myform.caller_uri.value,document.myform.callee_uri.value,1)" value="Send JSON"> </form> </body> </html>
What to do next
Install and start the new application.
Subtopics
- Assemble applications
Application assembly consists of creating Java EE modules that can be deployed onto application servers. The modules are created from code artifacts such as WAR files, resource adapter archive (RAR) files, enterprise bean (EJB) JAR files, and application client archive (JAR) files. This packaging and configuring of code artifacts into EAR modules or stand-alone web modules is necessary for deploying the modules onto an application server.
Related tasks
Assembling applications