【问题标题】:PHP SoapClient request: not a valid method for this servicePHP SoapClient 请求:不是此服务的有效方法
【发布时间】:2012-06-04 18:08:21
【问题描述】:

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

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

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

【问题讨论】:

    标签: php web-services soap soap-client


    【解决方案1】:

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

    试试这个

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

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

    【讨论】:

    • 我遇到了同样的问题并尝试了您的解决方案,但它不起作用。对此还有什么想法吗?
    • 这解决了我在用 PHP 7 切换 PHP 5.6 时遇到的问题 - 直接交换版本时可能会出现一些缓存问题。
    • 非常感谢!我正在尝试接受的答案,但列出了调用的函数,我不知道发生了什么:) 我也在 PHP 5.6 和 7.0 之间切换,就像 @iquito
    【解决方案2】:

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

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

    EchoTestRequest 不是有效的函数调用。正确的函数调用是 EchoTest,函数变量 dump 说明了这一点。

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

    【讨论】:

    • 这拯救了我的一天!如果某个函数在 WSDL 中列出但您无法调用它,请检查此答案,因为它将显示所有可用的函数。
    • 在意识到该方法不在列表中后,我将“?v=1”添加到 wsdl url 并且新的 wsdl 加载了新的可用方法。
    • 我遇到了类似的问题并尝试了您的答案,修复了 WSDL 文件。 var_dump() 仍然会给出相同的结果。原来它也在缓存 WSDL 文件。所以你的回答和this answer 一起解决了这个问题。谢谢。
    • @dsell,假设我有多个函数,例如。 ` 0 => string 'AirRepriceRsp service(AirRepriceReq $parameters)' (length=48) 1 => string 'ScheduleSearchRsp service(ScheduleSearchReq $parameters)' (length=56) 2 => string 'LowFareSearchRsp service(LowFareSearchReq $parameters)' (length=54)` 我需要调用一个特定的函数,我该怎么做。提前致谢。
    • 请帮我解决这个问题:stackoverflow.com/questions/60314839/…
    猜你喜欢
    • 2017-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多