Welcome Guest, Not a member yet? Register   Sign In
PHP5 soap capabilities in a library
#1

[eluser]tylderdurden[/eluser]
Hi there,

I'm trying to implement a generic library that will allow for use of PHP5's built in SoapClient capabilities, but I'm having trouble wrapping my head around it all.

What I want to accomplish

A library that I can load through $this->load->library('soapclient') while having the config stored in the right place in application/config.

This library will load up a WDSL file for web services that will let me use the methods are functions of the object.

What I've tried

I first tried it with the controller (just to see if it could work) with the following code:

Code:
<?php

    class Blog extends Controller{

        function index()
        {    
            $client = new SoapClient('WSDL_URI');

        $params = array(
                    'clientID' => 3444
                    );
            echo '<pre>';
            print_r($client->GetCountries($params));
            echo '</pre>';        
        
        }
    }
    
?&gt;

PHP just dies at this point with a "PHP has encountered an Access Violation at 010A9A8A". If I use var_dump($client->__getFunctions());, then it has no problems.

I gave up there and tried to create a library,

Code:
&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Soapclientci {
    
    function __construct()
    {
        $CI = & get_instance();
        $this->client = new SoapClient('WDSL_URI');
        $this->clientID = $CI->config->item('clientID');
    }

    function GetCountries()
    {
        $params = array(
                    'clientID' => 3444
                    );
        return $this->client->GetCountries($params);            
                    
        
    }
    
}

?&gt;

Sufficed to say, it didn't work either and I'm just totally lost and confused.

Any help in pointing me to the write place would be greatly appreciated.
#2

[eluser]tylderdurden[/eluser]
Making things way too complicated for myself. Smile

I figured it out.

Code:
&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Soap extends SoapClient{
    
    function __construct($wsdl){
        parent::__construct($wsdl);
    }

}

?&gt;

Code:
&lt;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

    $config['wsdl'] = 'http://webservices2-test.ticketnetwork.com/R2/TNServices.asmx?WSDL';
?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB