SoapClient to nusoap, Server did not recognize the value of HTTP Header SOAPAction

Infrid picture Infrid · Jul 8, 2013 · Viewed 11.7k times · Source

We are running PHP 5.3.18, for some strange reasons I can't install php-soap so that I can't use the SoapClient class...

I'm using now the last nusoap (should be compatible with php 5.3.18) and translating the code from SoapClient to nusoap_client.

This code use SoapClient and works perfectly

$s_WSPROTOCOL = 'https';
$s_WSHOSTNAME = 'xxxxxxxx.yyyyyy.tdl';
$s_WSPORT = '';
$s_WSPATHNAME = 'webservices/service.asp?WSDL';         
$s_WSTIPOOP = 'MyFunction';

$parameters['Username'] = '999';
$parameters['Login'] = 'Master';
$parameters['Password'] = 'universe';
$parameters['IdServ'] = '5';
$parameters['IdCard'] = '555';
$parameters['Controllo'] = '';

echo $s_WSTIPOOP."<br />";
echo $s_WSPROTOCOL."://".$s_WSHOSTNAME.$s_WSPORT."/".$s_WSPATHNAME."<br /><br /><br />";     

try 
{
    $SOAP = new SoapClient($s_WSPROTOCOL."://".$s_WSHOSTNAME.$s_WSPORT."/".$s_WSPATHNAME, array('trace' => 1));                
    $result = $SOAP->__soapCall($s_WSTIPOOP, array("parameters" => $parameters), null);
    foreach ($result as $key => $value) 
    {
      echo "<b>".$key."</b><br />";
      print_r($value);
      echo "<br />";
    }

}
catch (SoapFault $e) 
{        
    echo "<b>".$e->faultstring."</b>";
}           

This code in nusoap returns

[faultcode] => soap:Client
[faultstring] => Server did not recognize the value of HTTP Header SOAPAction: .
[detail] => 

here the code

require("nusoap/lib/nusoap.php");

error_reporting(E_ALL ^ E_NOTICE);
$ERROR_MSG = '';

$s_WSPROTOCOL = 'https';
$s_WSHOSTNAME = 'xxxxxxxx.yyyyyy.tdl';
$s_WSPORT = '';
$s_WSPATHNAME = 'webservices/service.asp?WSDL';         
$s_WSTIPOOP = 'MyFunction';

$parameters['Username'] = '999';
$parameters['Login'] = 'Master';
$parameters['Password'] = 'universe';
$parameters['IdServ'] = '5';
$parameters['IdCard'] = '555';
$parameters['Controllo'] = '';

echo $s_WSTIPOOP."<br />";
echo $s_WSPROTOCOL."://".$s_WSHOSTNAME.$s_WSPORT."/".$s_WSPATHNAME."<br /><br /><br />";     
$client = new nusoap_client($s_WSPROTOCOL."://".$s_WSHOSTNAME.$s_WSPORT."/".$s_WSPATHNAME);

$result = $client->call($s_WSTIPOOP, $parameters, '');

if ($client->fault) {
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; print_r($result); echo '</pre>';
} else {
$err = $client->getError();
if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>';
}
}

where is the mistake? I'm reading the code from nusoap source, trying with different arguments without success

Answer

Infrid picture Infrid · Jul 9, 2013

I have to set $wsdl parameter to true in order to work

$client = new nusoap_client($s_WSPROTOCOL."://".$s_WSHOSTNAME.$s_WSPORT."/".$s_WSPATHNAME, true);