cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1639
Views
10
Helpful
9
Replies

CCX HTTP Trigger POST support

James Hawkins
Level 8
Level 8

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?

 

POST /pdp/AuthorizationEndPoint HTTP/1.1
Host: 10.89.81.55:8080
Accept: */*
Content-type: text/xml; charset=ISO-8859-1
methodName: isRoleAccessAllowed
User-Agent: CiscoUCM-HttpClient/1.0
Connection:Keep-Alive
Content-Length: 1704
<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns="urn:oasis:names:tc:xacml:2.0:context:schema:os">
    <Subject SubjectCategory="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject">
        <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:role-id" DataType="http://www.w3.org/2001/XMLSchema#string" Issuer="requestor">
            <AttributeValue>CISCO:UC:UCMPolicy</AttributeValue>
        </Attribute>
        <Attribute AttributeId="urn:Cisco:uc:1.0:callingnumber" DataType="http://www.w3.org/2001/XMLSchema#string">
            <AttributeValue>+19725550101</AttributeValue>
        </Attribute>
        <Attribute AttributeId="urn:Cisco:uc:1.0:callednumber" DataType="http://www.w3.org/2001/XMLSchema#string">
            <AttributeValue>50102</AttributeValue>
        </Attribute>
        <Attribute AttributeId="urn:Cisco:uc:1.0:transformedcgpn" DataType="http://www.w3.org/2001/XMLSchema#string">
            <AttributeValue>+19725550101</AttributeValue>
        </Attribute>
        <Attribute AttributeId="urn:Cisco:uc:1.0:transformedcdpn" DataType="http://www.w3.org/2001/XMLSchema#string">
            <AttributeValue>+19725550102</AttributeValue>
        </Attribute>
    </Subject>
    <Resource>
        <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#anyURI">
            <AttributeValue>CISCO:UC:VoiceOrVideoCall</AttributeValue>
        </Attribute>
    </Resource>
    <Action>
        <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#anyURI">
            <AttributeValue>any</AttributeValue>
        </Attribute>
    </Action>
    <Environment>
        <Attribute AttributeId="urn:Cisco:uc:1.0:triggerpointtype" DataType="http://www.w3.org/2001/XMLSchema#string">
            <AttributeValue>translationpattern</AttributeValue>
        </Attribute>
    </Environment>
</Request>
9 Replies 9

James Hawkins
Level 8
Level 8

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!

I'm trying to follow what you're trying to do.

 

HTTP request -> UCCX trigger -> HTTP Request to download some XML file?

 

david

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

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.

Marek
Web: https://gaman-gt.com

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

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 '<', '>'.

Marek
Web: https://gaman-gt.com

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.

tannerezell
Level 1
Level 1

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

Thank you for releasing this information Tanner.