I managed to get a SOAP client working for a client but I am now trying to use REST for a slightly different project. I am using Httpful. From what I have read it is what I need in order to do what I've been asked.
This is my code so far.
/* MAIN RESTFUL */
$xml_file = './Project.xml';
$xsd_file = './Project.xsd';
$end_uri = 'https://****.com/Service.svc/CreateProject';
/* TEMP TEXTAREA FIELD */
if(!isset($_POST['submit']))
$_xml = file_get_contents($xml_file);
else
$_xml = $_POST['xml_input'];
echo '<form method="post" action=""><textarea name="xml_input" rows="10" cols="100">' . $_xml . '</textarea><br /><input type="submit" name="submit" value="Send"></form><br /><a href="./">Reset Form</a><br /><br />';
/* END TEMP TEXTAREA FIELD */
if(isset($_POST['submit']))
$xml_file = $_POST['xml_input'];
if(isset($_POST['submit']))
{
$xsd_validate = new DOMDocument();
$xsd_validate->loadXML($xml_file);
if($xsd_validate->schemaValidate($xsd_file))
$sendXML = true;
if($sendXML == true)
{
require('./httpful-master/bootstrap.php');
$request = \Httpful\Request::post($end_uri)
->body($xml_file)
->sendsXml()
->send();
if($request)
echo 'SENT!';
}
}
The guy I am working with doesn't really know a lot about REST either but apparently there is a way to retrieve a response from the request being sent. Does anyone know, or at least can point me in the right direction, to solve this?
Thanks.
EDIT: Sorry, just to elaborate. The XML is placed into the textarea field then validated against an XSD file. If this is successful it will then post that XML to the REST endpoint.