[eluser]Unknown[/eluser]
Hi, I'm just getting started with CI and OO, so apologies is this question is a bit basic...
I need to use a MS SOAP PHP extension class for an application, and was wondering if I could place it in the 'application/libraries/MSSoapClient.php' folder so I could reference when needed. I tried and it didn't work and I'm a bit confused.
Here is the class I would like to reference multiple times:
Code:
class MSSoapClient extends SoapClient {
function __doRequest($request, $location, $action, $version) {
$namespace = "http://tempuri.org/";
$request = preg_replace('/<ns :(\w+)/', '<$1 $request, 1);
$request = preg_replace('/<ns1:(\w+)/', '<$1', $request);
$request = str_replace(array('/ns1:', 'xmlns:ns1="'.$namespace.'"'), array('/', ''), $request);
// parent call
return parent::__doRequest($request, $location, $action, $version);
}
}
...and here is my code in a controller trying to add the library:
Code:
<?php
class Idcs_member_enrollment extends CI_Controller {
public function index(){
$this->load->library('MSSoapClient');
.....
FYI, I'm developing this locally running MAMP server. If I include the MSSoapClient class in the above Idsc_member_enrollment controller, underneath the primary class, it works. I assume this is not proper form. Here's an example of how it works, but would rather learn the right way.
Code:
<?php
class Idcs_member_enrollment extends CI_Controller {
public function index(){
$this->load->library('MSSoapClient');
/* Main code here */
}
}
class MSSoapClient extends SoapClient {
function __doRequest($request, $location, $action, $version) {
$namespace = "http://tempuri.org/";
$request = preg_replace('/<ns :(\w+)/', '<$1 $request, 1);
$request = preg_replace('/<ns1:(\w+)/', '<$1', $request);
$request = str_replace(array('/ns1:', 'xmlns:ns1="'.$namespace.'"'), array('/', ''), $request);
// parent call
return parent::__doRequest($request, $location, $action, $version);
}
}
Thanks in advance.