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

戏子无情 提交于 2019-12-23 20:13:34

问题


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


回答1:


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



回答2:


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



回答3:


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



来源:https://stackoverflow.com/questions/17524226/soapclient-to-nusoap-server-did-not-recognize-the-value-of-http-header-soapacti

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!