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

StackOverflow https://stackoverflow.com/questions/17524226

  •  02-06-2022
  •  | 
  •  

Вопрос

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

Это было полезно?

Решение

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);

Другие советы

Error is here

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

From where $client is comming?

I think you forgot to create the object for nusoap_client class

   $client = new nusoap_client();

After Your Edit

send the parameters as you are sending them in your first example,

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

This helped. Wrong namespace. If you are upgrading an old webservice, the owner may have kept the same old one, do not update it.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top