Hello folks!
I have a problem with which I would like to tweak your brain with since mine is tweaked out.
I have been working with SOAP for the last two weeks and am just now getting all the kinks worked out and started writing my own class. The code works fine outside of the class, but once I put it inside the class, it gives me:
<b>Fatal error</b>: Uncaught SoapFault exception: [Client] looks like we got no XML document in /www/testserver/htdocs/includes/class_MR.php:93
Stack trace:
#0 /www/testserver/htdocs/includes/class_MR.php(93): SoapClient->__soapCall('PingURL', Array, Array, Object(SoapHeader))
#1 /www/testserver/htdocs/ami/index.php(49): class_MR->getMultiSpeakData('PingURL')
#2 {main}
thrown in <b>/www/testserver/htdocs/includes/class_MR.php</b> on line <b>93</b><br />
Here is the code:
/**
* @author James Generaux
* @version 0.0.1alpha
* @copyright 2010 Carroll Electric Cooperative Corporation
*
*/
class class_MR {
// The current method [Defaults to PingURL set in __constructor()]
var $currentMethod = 'PingURL';
// The path to the server [Set Default Here]
var $serverPath = 'http://10.18.20.84/Optimum_Web_Service/MultiSpeak/30/MR_Server.asmx';
// The namespace [Set Default Here]
var $namespace = 'http://www.multispeak.org/Version_3.0';
// The SOAP Action [Default set in __constructor()]
var $soapAction;
var $headers; // Stores the SOAP Header
var $lastRequest; // Stores the last request to the SOAP Server
var $lastResponse; // Stores the last response from the SOAP Server
var $multiSpeakMsgHeader; // Stores the MultiSpeakMsgHeader string [Change Default in __constructor()]
var $multiSpeakUserID = 'USERNAME'; // The User ID [Set Default Here]
var $multiSpeakPwd = 'PASSWORD'; // The Password [Set Default Here]
var $multiSpeakAppName = 'MR_Server'; // The App Name [Set Default Here]
var $multiSpeakAppVersion = '1.0'; // The App Version [Set Default Here]
var $multiSpeakCompany = 'CECC'; // The Company [Set Default Here]
/**
* Simply sets the defaults
* @return void
*/
function __construct() {
$this->soapAction = "$this->namespace/$this->currentMethod";
$this->multiSpeakMsgHeader = 'MultiSpeakMsgHeader UserID="'.$this->multiSpeakUserID.'" Pwd="'.$this->multiSpeakPwd.'" AppName="'.$this->multiSpeakAppName.'" AppVersion="'.$this->multiSpeakAppVersion.'" Company="'.$this->multiSpeakCompany.'" xmlns="'.$this->namespace.' ';
}
/**
* Creates the Soap Client
* @return array The client data array
*/
function getMultiSpeakData($method) {
if ($method) {
$this->currentMethod = $method; // Set the Current Method
$this->soapAction = "$this->namespace/$this->currentMethod"; // Set the Soap Action
}
// Start Client
$client = new SoapClient(
NULL,
array(
'location' => $this->serverPath,
'uri' => $this->soapAction,
'trace' => true
)
);
echo $this->multiSpeakMsgHeader;
// Build the MultiSpeakMsgHeader to send in request
$this->headers = new SoapHeader(
$this->namespace,
$this->multiSpeakMsgHeader
);
// For Debugging
print_r($this->headers)."\
";
echo $this->currentMethod."\
";
echo $this->serverPath."\
";
echo $this->namespace."\
";
echo $this->soapAction."\
";
// Run Call
$client->__soapCall(
$this->currentMethod,
array(),
array(
'location' => $this->serverPath,
'uri' => $this->namespace,
'soapaction' => $this->soapAction
),
$this->headers
);
print_r($client)."\
";
// Store the last request and response
$this->lastRequest = $client->__getLastRequest();
$this->lastResponse = $client->__getLastResponse();
return $client;
}
}
// Create SOAP client.
$client = new class_MR();
echo $client->getMultiSpeakData('PingURL');
echo $client->lastRequest."\
";
echo $client->lastResponse."\
";
I’m pretty much clueless at the point as to why it fails on __soapCall() inside this class. You help will be much appreciated.
Thanks