Error when using a web service method in PHP

0

I'm working with SOA web services in PHP along with Zend Framework.

I created a simple service with methods on ($ firstName) and add ($ n1, $ n2) .

When running locally on my internal server (prolissatk / servico3 / server.php? wsdl and prolissatk / servico3 / client.php), the methods work.

Iuploadedtotheserver link .

Now the () method works, while the sum () method returns the error:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Server</faultcode>
         <faultstring>Procedure 'somar' not present</faultstring>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Followthewebservicedownloadlink: link

Follow the source code:

server.php

<?php
/* URL do servidor referente ao Webservice */
//$serverUrl = "http://www.prolissa.tk/servico3/server.php";
$serverUrl = "http://prolissatk/servico3/server.php";
?>

server.php

<?php
require_once __DIR__ . '/vendor/autoload.php';

/* URL do servidor referente ao Webservice */
require_once 'servidor.php';
$options = [
    'uri' => $serverUrl,
];

/* Classe do Webservice */
class Calculadora
{
    /**
     * Informacoes da calculadora.
     *
     * @param string $firstName
     * @return string $greetings
     */
    public function sobre($firstName)
    {
        return 'Calculadora matemática. Desenvolvedor: ' . $firstName;
    }

    /**
     * Somar dois numeros.
     *
     * @param integer $n1
     * @param integer $n2
     * @return integer $somaResultado
     */
    public function somar($n1, $n2) {
        $somaResultado = $n1 + $n2;
        return $somaResultado;
    }
}

$server = new Zend\Soap\Server(null, $options);

if (isset($_GET['wsdl'])) {
    $soapAutoDiscover = new \Zend\Soap\AutoDiscover(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeSequence());
    $soapAutoDiscover->setUri($serverUrl);

    $soapAutoDiscover->setOperationBodyStyle(array('use' => 'literal'));
    $soapAutoDiscover->setBindingStyle(array('style' => 'document'));

    $soapAutoDiscover->setClass('Calculadora');

//    header("Content-Type: text/xml");
//    echo $soapAutoDiscover->generate()->toXml();
    $soapAutoDiscover->handle();
} else {
    $soap = new \Zend\Soap\Server($serverUrl . '?wsdl');
    $soap->setObject(new \Zend\Soap\Server\DocumentLiteralWrapper(new Calculadora()));
    $soap->handle();
}
?>

client.php

<?php
require_once __DIR__ . '/vendor/autoload.php';

/* URL do servidor referente ao Webservice que será consultado */
require_once 'servidor.php';
$serverUrl = $serverUrl . '?wsdl';

/* Instânciando o cliente */
$client = new Zend\Soap\Client($serverUrl);

/* Chamando métodos */
$result = $client->sobre(['firstName' => 'Diego']);
$result2 = $client->somar(['n1' => 4, 'n2' => 3]);

/* Exibindo os resultados */
echo $result->sobreResult . '<br/>';
echo $result2->somarResult . '<br/>';
?>

phpinfo () from the server: link

What should I do to make the service work on the server?

    
asked by anonymous 25.09.2018 / 01:59

0 answers