XML data collection with HTTP POST requests is not working

Description

The XML Collector was enhanced on 1.12 in order to process XML/HTML data from HTTP POST requests.

Unfortunately, there is a problem on the implementation of org.opennms.protocols.xml.collector.AbstractXmlCollectionHandler when replacing the placeholders on the configured Request, which prevents the proper behavior of the XML Collector with HTTP POST requests.

Acceptance / Success Criteria

None

Lucidchart Diagrams

Activity

Alejandro Galue May 6, 2015 at 2:12 PM

Here is the core of the fix (useful for fixing an older version of OpenNMS):

diff --git a/protocols/xml/src/main/java/org/opennms/protocols/xml/collector/AbstractXmlCollectionHandler.java b/protocols/xml/src/main/java/org/opennms/protocols/xml/collector/AbstractXmlCollectionHandler.java index 9a7e911..80ad503 100644 --- a/protocols/xml/src/main/java/org/opennms/protocols/xml/collector/AbstractXmlCollectionHandler.java +++ b/protocols/xml/src/main/java/org/opennms/protocols/xml/collector/AbstractXmlCollectionHandler.java @@ -386,6 +386,7 @@ public abstract class AbstractXmlCollectionHandler implements XmlCollectionHandl return null; final OnmsNode node = getNodeDao().get(agent.getNodeId()); final Request request = new Request(); + request.setMethod(unformattedRequest.getMethod()); for (Header header : unformattedRequest.getHeaders()) { request.addHeader(header.getName(), parseString(header.getName(), header.getValue(), node, agent.getHostAddress(), collectionStep)); }

In case someone requires this functionality on a version older than 16.0.0, the user should recompile protocols/xml from the source after applying the above patch.

Alejandro Galue May 6, 2015 at 1:58 PM

Fixed on revision 240d48f92c15d2f5c91808130f526f7a010eaa5d for foundation, and merged to develop on revision c62cc243d52c25c81d2cc6ae287ecd5062ae1f5d.

Fixed

Details

Assignee

Reporter

Priority

PagerDuty

Created May 6, 2015 at 1:52 PM
Updated May 6, 2015 at 5:53 PM
Resolved May 6, 2015 at 1:58 PM

Flag notifications