[eluser]Unknown[/eluser]
I Finally fixed several issues I had:
My code:
Code:
<?php
class Webservice extends CI_Controller {
function Webservice() {
parent::__construct();
$this->load->library("nusoap_lib");
$this->nusoap_server = new soap_server();
$this->nusoap_server->configureWSDL("WebServiceG2", "urn:WebServiceG2");
$this->nusoap_server->register(
"sendFile",
array(
"name" => "xsd:string",
"content" => "xsd:string"
),
array("return"=>"xsd:string"),
"urn:WebServiceG2",
"urn:WebServiceG2#getFile",
"rpc",
"encoded",
"Sends a file using SOAP to G2"
);
$this->nusoap_server->register(
"welcomeMember",
array(
"name" => "xsd:string",
"sex" => "xsd:string",
"phone" => "xsd:string",
"memberID" => "xsd:int",
"language" => "xsd:string"
),
array("return"=>"xsd:string"),
"urn:WebServiceG2",
"urn:WebServiceG2#welcomeMember",
"rpc",
"encoded",
"Sends new member parameters, welcome"
);
}
function index() {
function sendFile($name,$content) {
//return $name.",".$content;
libxml_use_internal_errors( true );
$doc = new DOMDocument('1.0', 'utf-8');
$doc->loadXML(base64_decode($content));
$errors = libxml_get_errors();
if(empty($errors)){
$fichNuevo = $name;
$fichNuevo = fopen($fichNuevo,'w');
fwrite($fichNuevo,$content);
fclose($fichNuevo);
return "TRANSFERENCIA CORRECTA";
}else{
return "FALLO EN FORMATO XML";
}
}
function welcomeMember($name=null,$sex=null,$phone=null,$memberID=null,$language=null) {
if($name and $sex and $phone and $memberID and $language){
return "USUARIO RECIBIDO";
}else{
return "USUARIO INCORRECTO";
}
}
$this->nusoap_server->service(file_get_contents("php://input"));
}
}
?>
With that I can call the "http//myURL.webservice/index?wsdl" and it will work without any route to be added and any code in the index file.
And the most important part for me was to add inside the index function all the soap services functions, without that It was not working if I was using the "default" wsdl instead of using the specific "http//myURL.webservice/sendFile/index/wsdl" or the other one. I don't know if you know what I mean...