Hello all,
I am trying to build a client to consume a webservice, and have run into some strange issues. Here is my code:
$securityCode = "A7D5B7D8-73E2-44D2-A6F8-4ACFB91843BF"; // The security code has been changed to an invalid code to prevent unwanted "visitors".
$ProphecyConnect = new SoapClient("http://test.prophecyhealth.com/ProphecyConnect/ProphecyConnectXML.cfc?wsdl");
try
{
$params = array(SecurityCode => $securityCode, AssessmentID => -1, AssessmentType => "Test");
$assessmentList = $ProphecyConnect->__soapCall("GetAssessments", array($params));
}
catch(Exception $exception)
{
var_dump($exception);
}
$xml = new DOMDocument();
$xml->loadXML( $assessmentList );
try
{
foreach($xml->getElementsByTagName("assessment") as $assessment)
{
foreach($assessment->childNodes as $node)
{
printf(
"Name: %s - Type: %s - Value: %s\n",
$node->nodeName,
$node->nodeType,
urlencode($node->nodeValue)
);
}
}
}
catch(Exception $ex)
{
echo "Something happened.";
var_dump($ex);
}
My problem is that the getElementByTagName never finds anything. This is the returned XML from the webservice:
<object>
<success>true</success>
<count>3</count>
<assessments>
<assessment>
<assessmentid><![CDATA[201]]></assessmentid>
<assessmentname><![CDATA[Cardiac Cath Lab V1]]></assessmentname>
<assessmenttype><![CDATA[Test]]></assessmenttype>
<costpoints><![CDATA[1]]></costpoints>
<numberofquestions><![CDATA[23]]></numberofquestions>
<timelimit><![CDATA[1380]]></timelimit>
</assessment>
<assessment>
<assessmentid><![CDATA[695]]></assessmentid>
<assessmentname><![CDATA[Cardiac Progressive Care Exam A V1]]></assessmentname>
<assessmenttype><![CDATA[Test]]></assessmenttype>
<costpoints><![CDATA[1]]></costpoints>
<numberofquestions><![CDATA[75]]></numberofquestions>
<timelimit><![CDATA[4500]]></timelimit>
</assessment>
<assessment>
<assessmentid><![CDATA[708]]></assessmentid>
<assessmentname><![CDATA[Cardiac Progressive Care Exam B V1]]></assessmentname>
<assessmenttype><![CDATA[Test]]></assessmenttype>
<costpoints><![CDATA[1]]></costpoints>
<numberofquestions><![CDATA[75]]></numberofquestions>
<timelimit><![CDATA[4500]]></timelimit>
</assessment>
</assessments>
</object>
I'm quite the n00b when it comes to PHP, but as far as I can tell, this looks right (at least close). I'm sure I'm missing something blatently obvious though.
Thanks