[eluser]Nathan Pitman (Nine Four)[/eluser]
So I've installed the NuSoap Library from the Wiki (
http://codeigniter.com/wiki/CI_Nusoap_Library/) and it seems to work (kinda) but perhaps becuase I'm using segments and not querystrings for my app I've run into problems.
If I query the web services page to display the wsdl it returns a 404, I guess becuase of the '?' in the URL. I've tried adding a rule to routes.php to overcome this but no luck...
Code:
$route['web_services/:any'] = "web_services";
Any ideas? It's so close to working yet so far! I've included my controller code below:
Code:
<?php
class Web_services extends Controller {
function Web_services()
{
parent::Controller();
$this->load->library('nusoap');
$this->load->model('result');
}
function index()
{
$namespace = "http://www.mydomainname.co.uk/web_services";
$server = new soap_server();
$server->debug_flag = false;
$server->configureWSDL("CompanyName - WSDL", $namespace);
$server->wsdl->schemaTargetNamespace = $namespace;
// Single Result Type
$server->wsdl->addComplexType(
'Result',
'complexType',
'struct',
'all',
'',
array(
'ResultId' => array('name' => 'ResultId',
'type' => 'xsd:int'),
'ResultEmail' => array('name' => 'ResultEmail',
'type' => 'xsd:string'),
'ResultFirstname' => array('name' => 'ResultFirstname',
'type' => 'xsd:string'),
'ResultSurname' => array('name' => 'ResultSurname',
'type' => 'xsd:string')
)
);
$server->register('GetResult', // method name
array('UserEmail' => 'xsd:string','ProductRef' => 'xsd:string','ClientId' => 'xsd:int'), // input parameters
array('return' => 'tns:Result'), // output parameters
$namespace, // namespace
$namespace . '#GetResult', // soapaction
'rpc', // style
'encoded', // use
'Get a users results' // documentation
);
// Get a specific users result for a specific product
function GetResult($email, $product_ref='FW', $client_id)
{
$query = $this->result->get_ws_result($email, $product_ref, $client_id);
return array(
"ResultId" => $query->id,
"ResultEmail" => $query->email,
"ResultFirstname" => $query->firstname,
"ResultSurname" => $query->surname
);
}
// Output
$HTTP_RAW_POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA'])
? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
$server->service($HTTP_RAW_POST_DATA);
exit();
}
}
?>