Why doesn't work nusoap in Codeigniter 4?

80 views Asked by At

Please help me, I can't find solution for my problem. We have an old website and want to rewrite in CI4. We have a lot of SOAP webservices using nusoap. There is no option to replace these webservices because more then 4000 of our clienst are using them. We recreated one of these webservices in CI4, but have some issues. First of all if we check the WSDL, it shows two html input fields.

enter image description here

So we get around to have the wsdl, created this code:

<?php
namespace App\Controllers\Api\NAV;

use CodeIgniter\Controller;

class wsNav extends Controller
{
    protected $server;

    function __construct(){
        helper("soapout_xml_helper");
    }

    function register(){
        require_once(str_replace("\\","/",APPPATH).'Libraries/SOAP/nusoap.php');
    $this->server = new \soap_server("", array("encoding"=>"utf-8"));
    $this->server->configureWSDL('NavServices', 'urn:NavServices');
    $this->server->register('validateApehXml',
            array('hash' => 'xsd: string', 
                  'apeh_xml' => 'xsd: string',             
                  'language' => 'xsd: string'),
            array('return' => 'xsd:xml'),
            'NavServices',
            'xsd:NavServices');
    }

    public function index()
    {
        $this->register();
        $this->server->service(file_get_contents("php://input"));
    }

    public function wsdl()
    {
        $this->register();
        $wsdlContent = $this->server->wsdl->serialize();
        $response = $this->response
                    ->setContentType('application/xml')
                    ->setBody($wsdlContent);
                return $response;
    }

    public function validateApehXml($hash, $apeh_xml, $language='hu') {
        $ret = array(
                'errorCode' => '10'
                , 'return' => 'Hash : '.$hash
                , 'errorDesc' => 'ApehXml: '.$apeh_xml
        );
        if ($apeh_xml == "") {
            $ret['errorCode'] = '1';
            $ret['errorDesc'] = "Empty ApehXml";
            return createxml('result', $ret);       
        }

        return createxml('result', $ret);
    }
}

So we have the wsdl: enter image description here

And we have no idea why. Does anybody met with this? Any help will be appriciated! Thank you!

But if we test this code in SOAPUI we get this:

<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
        <faultcode xsi:type="xsd: string">SOAP-ENV:Client</faultcode>
        <faultstring xsi:type="xsd: string">method 'validateApehXml'('validateApehXml') not defined in service('' '')</faultstring>
        <faultactor xsi:type="xsd: string"/>
        <detail xsi:type="xsd: string"/>
      </SOAP-ENV:Fault>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

And we have no idea why. Does anybody met with this? Any help will be appriciated! Thank you!

0

There are 0 answers