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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10817430/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 23:07:20  来源:igfitidea点击:

PHP SoapClient request: not a valid method for this service

phpweb-servicessoapsoap-client

提问by dsell002

Okay, I think I need another pair of eyes to look over this. I'm making a simple php soapclient call to an echo web service on a remote server. I'm pretty sure I don't have any typos and that the function call is correct. However, I'm receiving a fatal error claiming the function isn't a valid method. Below is a var_dump of the web services types.

好吧,我想我需要另一双眼睛来看看这个。我正在对远程服务器上的 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; }" }

Fatal error: Uncaught SoapFault exception: [Client] Function ("EchoTestRequest") is not a valid method for this service in /home/grafixst/public_html/cpaapp/echo_test.php:38 Stack trace: #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} thrown in /home/grafixst/public_html/cpaapp/drew/echo_test.php on line 38

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 异常:[Client] 函数(“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 中抛出

Here is the code I'm using to make the call:

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

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

回答by dsell002

A simple request for the web service's available functions solved the problem.

对 Web 服务的可用功能的简单请求解决了这个问题。

$functions = $client->__getFunctions ();
var_dump ($functions);

EchoTestRequest was not a valid function call. The proper function call was EchoTest, which is illustrated by the functions variable dump.

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

array(1) { [0]=> string(54) "EchoTestResponse EchoTest(EchoTestRequest $parameters)" } 

回答by ZenithS

I assume you're not typo and the method is actually available.

我假设您没有打错字,并且该方法实际上可用。

Try this

尝试这个

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

It's might be because of wsdl was cached.

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