PHP SoapClient请求:不是此服务的有效方法

dse*_*002 14 php soap web-services soap-client

好吧,我想我需要另外一双眼睛来看看这个.我正在对远程服务器上的echo Web服务进行简单的php soapclient调用.我很确定我没有任何拼写错误,而且函数调用是正确的.但是,我收到一个致命的错误声称该函数不是一个有效的方法.下面是Web服务类型的var_dump.

array(4){[0] => string(88)"struct EspException {string Code; string Audience; string Source; string Message;}"[1] => string(71)"struct ArrayOfEspException {string Source; EspException Exception ;}"[2] => string(43)"struct EchoTestRequest {string ValueIn;}"[3] => string(45)"struct EchoTestResponse {string ValueOut;}"}

致命错误:未捕获的SoapFault异常:[客户端]函数("EchoTestRequest")不是/home/grafixst/public_html/cpaapp/echo_test.php:38中此服务的有效方法.堆栈跟踪:#0/home/grafixst/public_html /cpaapp/echo_test.php(38):SoapClient - > __ call('EchoTestRequest',Array)#1 /home/grafixst/public_html/cpaapp/echo_test.php(38):SoapClientAuth-> EchoTestRequest(Array)#2 {main }在第38行的/home/grafixst/public_html/cpaapp/drew/echo_test.php中抛出

这是我用来拨打电话的代码:

require_once('SoapClientAuth.php');

ini_set("soap.wsdl_cache_enabled", "0");

#- Loading the WSDL document
$server = "https://wsonline.seisint.com/WsAccurint/EchoTest?ver_=1.65";
$wsdl = $server . "&wsdl";     

$client = new SoapClientAuth($wsdl,
                array(
                      'login' => $username,
                      'password' => $password
                     ));   

$types = $client->__getTypes();

var_dump($types);

echo "</br>";

$req = $client->EchoTestRequest(array('ValueIn' => 'echo'));

print $req->ValueOut;
echo "</br>";
Run Code Online (Sandbox Code Playgroud)

dse*_*002 51

对Web服务可用功能的简单请求解决了该问题.

$functions = $client->__getFunctions ();
var_dump ($functions);
Run Code Online (Sandbox Code Playgroud)

EchoTestRequest不是有效的函数调用.正确的函数调用是EchoTest,它由函数变量dump说明.

array(1) { [0]=> string(54) "EchoTestResponse EchoTest(EchoTestRequest $parameters)" } 
Run Code Online (Sandbox Code Playgroud)

  • 这挽救了我的一天!如果WSDL中列出了一个功能,但您不能调用它,请检查此答案,因为它将显示所有可用功能。 (2认同)

Zen*_*thS 21

我假设你不是拼写错误,方法实际上是可用的.

试试这个

ini_set("soap.wsdl_cache_enabled", "0");
Run Code Online (Sandbox Code Playgroud)

这可能是因为wsdl被缓存了.

  • 当用PHP 7切换PHP 5.6时,这解决了我的问题 - 在直接交换版本时可能存在一些缓存问题. (8认同)