【问题标题】:Handle dots in Soap names with PHP使用 PHP 处理 Soap 名称中的点
【发布时间】:2015-09-18 13:54:02
【问题描述】:

我有一个 wsdl,当在 soapui 中打开时会显示以这种方式命名的方法:

  • DTL.GP.03.RC.Method1
  • DTL.GP.04.RC.Method2

我找不到在 PHP Soapclient 中使用这些名称的方法。名字中的点把代码搞砸了。有人知道方法吗?

【问题讨论】:

    标签: php soap soapui


    【解决方案1】:

    http://php.net/manual/es/function.call-user-func.php。并且 __getFunctions 返回可用 SOAP 函数的列表。

    这里有一些例子:

    $client = new SoapClient(__DIR__."/helloservice.wsdl");
    echo var_export($client->__getFunctions(), true);
    
    $param1 = "nacho";
    
    echo "eg 1\n";
    echo call_user_func(array($client, "DTL.GP.03.RC.Method1"), $param1 /* , ... */)."\n";
    
    echo "eg 2\n";
    $method="DTL.GP.03.RC.Method1";
    echo $client->$method($param1)."\n";
    

    输出:

    array (
      0 => 'string DTL.GP.03.RC.Method1(string $firstName)',
    )eg 1
    Hello nacho
    eg 2
    Hello nacho
    

    我在 PHP 5.5.27 中尝试过,但也适用于 PHP 5.3。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-07
      相关资源
      最近更新 更多