Description
From: grouper-users-request grouper-users-request On Behalf Of Bryan E. Wooten
Sent: Monday, February 10, 2014 4:19 PM
To: grouper-users
Subject: [grouper-users] Grouper ESB patch for ActiveMQ<5.10
Problem description: Grouper correctly submits POSTs with raw JSON-data using Content-Type of “application/json”. However, ActiveMQ (unexpectedly) only accepts POSTs where the JSON is preceded by “body=”; additionally, I can only get this to work when setting Content-Type to "application/x-www-form-urlencoded” using a key of “body” and placing the data as the value (contrary to what a related AMQ bug-ticket seems to claim can be done by setting Content-Type to “text/xml”).
ie:
POST /api/message/MyQueue?type=someType HTTP/1.1
Host: localhost:8161
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
body=MyJsonData
Workaround-patch: in file edu.internet2.middleware.grouper.changeLog.esb.consumer.EsbHttpPublisher
At around line 72 we find this line:
post.setRequestHeader("Content-Type", "application/json; charset=utf-8”);
Based on some configuration, this needs to be optionally:
post.setRequestHeader("Content-Type", "application/x-www-form-urlencoded”);
At around line 75 we find this line:
requestEntity = new StringRequestEntity(eventJsonString, "application/json", "utf-8”);
Based on the same configuration, this needs to be optionally:
requestEntity = new StringRequestEntity( "data=" + eventJsonString, "application/x-www-form-urlencoded”, "utf-8");
Note: this problem only appears to apply to AMQ 5.8 and 5.9 — it is scheduled to be fixed in 5.10
See: https://issues.apache.org/jira/browse/AMQ-4668