01-29-2020 07:33 AM
Hi,
I have a CCX 11.6 Premium system and need to know if what I am trying to do is supported.
I want to make a HTTP POST request to a CCX HTTP trigger which posts an XML file which I then want to save on the UCCX server and parse the content.
I have tried using the Get HTTP Contact Info step but cannot work out how to save the XML content in the POST request.
Below is an example of an inbound POST request - you may recognise it from the CURRI developer guide.
Does anyone know if this is possible?
01-30-2020 02:47 AM
I have spent some time on this and am coming to the conclusion it is not possible.
The Get HTTP Contact Info step seems to be able to read information from the request headers and parameters but not from the body of the request which is where the XML content is located.
Any suggestions welcome!
01-30-2020 12:46 PM
I'm trying to follow what you're trying to do.
HTTP request -> UCCX trigger -> HTTP Request to download some XML file?
david
01-30-2020 01:30 PM
Hi David,
Thanks for responding. The service I have in mind is based upon Cisco Unified Routing Rules XML Interface (CURRI).
This is a CUCM feature that can be enabled on Directory Numbers, Translation Patterns and Route Patterns and allows various features such as playing a message before connecting, dropping or diverting a call or changing the calling/called number or name.
When CURRI is enabled on a number it is triggered when a call hits the number pattern. CUCM then sends a HTTP POST to a URL. The body of this HTTP post contains XML which contains details of the calling and called numbers amongst other stuff.
I wanted to be able to read the XML content from the body of the HTTP POST that was sent to a UCCX trigger, parse it to learn the called number and then do a database lookup to check what message (if any) should be played for calls to that number and whether the call should be allowed, blocked or diverted.
The UCCX Get HTTP Request Info step allows me to read Headers and Parameters from inbound requests but not read the content in the body of the post as far as I can make out.
Hope this makes what I am trying to do clearer.
Cheers
James
01-30-2020 02:12 PM
Hi James,
I think you are right and you will not be able to directly read the content of the request. But it looks (for POST requests) like the system allows you to read the content as parameters are passed in the request body.
This definitely will not work for the data structure from CURRI as it's XML based.
But if you can put between CUCM and UCCX some middleware - HTTPP request forwarder - that would convert the content that looks like POST request:
parameter=xml_content
then it would be possible to get XML content in the script and then parse and store it in the desired location.
01-30-2020 02:58 PM
Thanks Marek,
Implementing some form of middleware is a good idea. I mess about with Python a bit so I will try using that to convert between the formats.
Cheers
James
01-30-2020 03:36 PM
I recommend that you start with Postman and simulate middleware behavior - like in the final solution This way you can easily confirm if the idea of middleware will work. Maybe it will require some additional processing tasks - like escaping the '<', '>'.
07-24-2020 01:07 PM
Anthony brought this post to my attention today and I've played around with it. It's definitely possible, but not straightforward. Message me if you need to get into this can of worms.
08-10-2020 03:14 PM
Here ya go:
{ // Author: Tanner Ezell (tanner.ezell@ctilogic.com) // USE AT YOUR OWN RISK // Will probably break if Cisco makes underlying changes. Class servletClass = Class.forName("javax.servlet.ServletRequest"); java.lang.reflect.Method getRequestMethod = contact.getClass().getDeclaredMethod("getRequest", null); java.lang.reflect.Method getReaderMethod = servletClass.getDeclaredMethod("getReader", null); getRequestMethod.setAccessible(true); Object request = (getRequestMethod.invoke(contact, null)); java.io.BufferedReader reader = (java.io.BufferedReader) getReaderMethod.invoke(request, null); StringBuilder builder = new StringBuilder(); String line; while( (line = reader.readLine()) != null) { builder.append(line); } return builder.toString(); }
You'll need a Contact variable (name: contact, type: Contact), and set this expression as the return value in a Set step. Whatever the body's contents are will be returned.
Be aware that this could easily break. Cisco won't support you.
HTH
Regards,
Tanner Ezell
08-10-2020 05:14 PM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide