(imported topic written by SMcQueen)
I’m trying to publish a page where we can pull group memberships onto a web page using PHP and SOAP to pull from the reporting system. Thanks to Lee and
this post
I have the following php code set-up with a simple query just to get some response.
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$WSDL="https://myserver/webreports?wsdl";
$Location="https://myserver/webreports";
$Username="ReportUser";
$Password="ReportPass";
$Relevance="names of bes sites";
$URI="http://schemas.bigfix.com/Relevance";
echo "<br>";
echo "Username = $Username <br> ";
echo "Password = $Password <br> ";
echo "Relevance = \"$Relevance\"<br>";
echo "Location = $Location <br>";
echo "URI = $URI <br>";
echo "<br>create client handle <br>";
$client = new SoapClient($WSDL,
array(
"location" => $Location,
"uri" => $URI,
"style" => SOAP_RPC,
"use" => SOAP_ENCODED,
"trace" => 1));
echo "send request <br>";
echo "<br>";
$results = ($client->__soapcall("GetRelevanceResult",
array(
new SoapParam($Relevance, "relevanceExpr"),
new SoapParam($Username, "username"),
new SoapParam($Password, "password")),
array(
"uri" => $URI,
"soapaction" => $URI."/GetRelevanceResult")). "\n");
echo "Parse Response";
$str = ($client->__getLastResponse()); $str = str_replace("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">", " ", $str);
$str = str_replace("<soapenv:Body>", " ", $str);
$str = str_replace("<GetRelevanceResultResponse xmlns=\"".$URI."\">", "<GetRelevanceResultResponse>", $str);
$str = str_replace("</soapenv:Body>", " ", $str);
$str = str_replace("</soapenv:Envelope>", " ", $str);
$xml = simplexml_load_string($str);
echo 'Results from BigFix SOAP API<br /><br />';
foreach($xml as $soapresponse)
{
echo $soapresponse.'<br />';
}
?>
The output looks like…
Username = SOAPUser
Password = SOAPPass
Relevance = "names of bes sites"
Location = https://myserver/webreports
URI = http://schemas.bigfix.com/Relevance
create client handle
send request
Fatal error: Uncaught SoapFault exception: [env:Client] XML parsing error:
Element '{http://schemas.bigfix.com/Relevance}GetRelevanceResult' cannot
be empty according to the DTD/Schema. Line 2, Character 166 in
/var/www/html/index.php:44 Stack trace: #0 /var/www/html/index.php(44):
SoapClient->__soapCall('GetRelevanceRes...', Array, Array) #1 {main}
thrown in /var/www/html/index.php on line 44
As such, I’m thinking there is a problem with my soapcall (particularly with my second array element. I have tried running the query in SoapUI and get a good list of the sites back so I know the service is working on the BES side of things even with the https URL, so I don’t think it is an SSL problem.
Help. thanks!