Defining a NuSOAP server within a class definition
Pretty simple. Due to the requirements of my project, I have to create a
NuSOAP server within a class definition. I cannot get it to work. I get a
fault back with this error message: "error in msg parsing: xml was empty,
didn't parse!" What do I need to make this work?
This is the bare minimum code that I am trying to use to achieve this. If
I rewrite this code outside of a class definition, it works easily.
<?php
require_once('/var/www/njdrp/library/nusoap/nusoap.php');
class MyService {
private $_namespace;
private $_server;
// Initialize action controller here.
public function __construct() {
$this->_namespace = 'uri:mycompany';
$this->_server = new soap_server;
$this->_server->configureWSDL('mycompany',$namespace);
$this->registerSomeMethod();
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ?
$HTTP_RAW_POST_DATA : '';
$this->_server->service($HTTP_RAW_POST_DATA);
}
public static function SomeMethod(
$someParameter
) {
return "Success: $someParameter!";
}
function registerSomeMethod() {
$in = array();
$in['someParameter'] = 'xsd:string';
$out = array();
$out['return'] = 'xsd:string';
$this->_server->register("SomeMethod",$in,$out,$this->_namespace,"SomeMethod","rpc","encoded");
}
} // class
$o = new MyService;
?>
No comments:
Post a Comment