Custom Scripting Service XML Notifier Invalid XML Payload Error


#1

I am writing a CSS Notifier service in PHP to receive XML notification data. I have managed to get the authentication working, but the XML Payload (sent as POST Body) is bombing with the error “Invalid XML Payload Supplied”.

The XML Data being sent looks like this:
<?xml version="1.0" encoding="UTF-8"?> <submission-notification> <form> <id type="integer">1</id> <name>FORM_NAME</name> <guid>FORM_GUID</guid> </form> <submission> <guid>SUBMISSION_GUID</guid> </submission> </submission-notification>

Im using SimpleXML to read in the payload data:

	curl -i -k -3 -X POST https://relay.wastestrategies.com/rest/user/session 
	 -H "X-DreamFactory-Application-Name: canvasnotifier" 
	 -d "{ \"email\" : \"user@example.com\", \"password\" : \"Password\" }"

	$dataPOST = trim(file_get_contents("php://input"));
	$xmlData = simplexml_load_string($dataPOST);

	$notification = new SimpleXMLElement($xmlData);

	if(!isset( $notification->submission[0]->guid )){
		http_response_code(406);
	];    return [
	        "success" => false,
	        "message" => "Missing submission GUID in params"
	    ];
	}

	$submission_guid = $notification->submission[0]->guid;
	http_response_code(200);
	return [
	    "success" => true,
	    "result"  => $submission_guid
	];

Any ideas why the payload would be invalid?


#2

FYI, After some troubleshooting by the engineer it seems the xml payload needs to be wrapped in tag for the type caster not to choke on the content. There is a request going in to allow the content through if the tag is missing and allow for the xml data to processed.

I’m interested if anyone has run into this before consuming 3rd party api xml data.


#3

Any update on this? This wrapper requirement is killing me.


#4

Looking into it, will have an answer for you Monday.


#5

For anybody reading this after the fact, this fix is in the release coming out later this month, and is already in the develop branch of df-core.


#6

I am also having the same problem while testing the service in Canvas Notification API , i am getting Response Code 500

I am using Spring Rest to receive call and it comsumes=“application/xml”

Can any body solve this problem