1

Building a punchout system and the data supplied by POST is cXML. What is the best way to process through the cXML data?

I am trying to pull out certain values (username, password etc) and am generating an XML file to return to the supplier.

I have the second part done but it's the handling of the POST that has me stuck. I have been banging my head trying to get $_POST to convert the data back into cXML.

Once I have the data in I can process it:

$senderIdentity = $xml->Header->Sender->Credential->Identity;
$senderSharedSecret = $xml->Header->Sender->Credential->SharedSecret;
$buyerCookie = $xml->Request->PunchOutSetupRequest->BuyerCookie;
$requestURL = $xml->Request->PunchOutSetupRequest->BrowserFormPost->URL;
$payloadID = $xml->attributes()->payloadID;

It's just the initial pull in that I can't get correct.

Eventually this will be put onto a HTTPS if that has any influence.

Any help would be appreciated.

regards, Robert

VettelS
  • 1,204
  • 1
  • 9
  • 17
rmccallum
  • 214
  • 3
  • 18
  • Once I have the data I am able to manipulate it: – rmccallum Mar 08 '12 at 17:12
  • cXML suggests there is some specification of it (please link it) and also that it's XML. Next to format specifics your question is probably just about how to retrieve the raw post data in PHP, see [Get raw post data](http://stackoverflow.com/questions/1361673/get-raw-post-data) and [Improved handling of HTTP requests in PHP](https://gist.github.com/1028251). – hakre Mar 08 '12 at 17:16
  • you usually just have to put the XML document from the POST into some sort of XML processor, e.g. DOM, SimpleXML or XMLReader. So I guess you have to explain more about your POST data. Please show the code to get the POST or at least show the POST data. – Gordon Mar 08 '12 at 17:36

1 Answers1

1

I got this sorted using:

file_get_contents('php://input')

And then using simplexml_load_string based on the input received.

rmccallum
  • 214
  • 3
  • 18