PHP Soap 非 WSDL 调用:如何传递参数?

PHP Soap non-WSDL call: how do you pass parameters?(PHP Soap 非 WSDL 调用:如何传递参数?)
本文介绍了PHP Soap 非 WSDL 调用:如何传递参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试像这样在 PHP (5.2.5) 中进行非 WSDL 调用.我确定我错过了一些简单的东西.这个调用有一个参数,一个字符串,叫做时区":

I'm trying to make a non-WSDL call in PHP (5.2.5) like this. I'm sure I'm missing something simple. This call has one parameter, a string, called "timezone":

    $URL = 'http://www.nanonull.com/TimeService/TimeService.asmx';

    $client = new SoapClient(null, array(
        'location' => $URL,
        'uri'      => "http://www.Nanonull.com/TimeService/",
        'trace'    => 1,
        ));

// First attempt:
// FAILS: SoapFault: Object reference not set to an instance of an object
   $return = $client->__soapCall("getTimeZoneTime",
       array(new SoapParam('ZULU', 'timezone')),
       array('soapaction' => 'http://www.Nanonull.com/TimeService/getTimeZoneTime')
    );

// Second attempt:
// FAILS: Generated soap Request uses "param0" instead of "timezone"
   $return = $client->__soapCall("getTimeZoneTime",
       array('timezone'=>'ZULU' ),
       array('soapaction' => 'http://www.Nanonull.com/TimeService/getTimeZoneTime')
   );

感谢您的建议
-戴夫

Thanks for any suggestions
-Dave

推荐答案

谢谢.这是现在有效的完整示例:

Thanks. Here's the complete example which now works:

$URL = 'http://www.nanonull.com/TimeService/TimeService.asmx';

$client = new SoapClient(null, array(
    'location' => $URL,
    'uri'      => "http://www.Nanonull.com/TimeService/",
    'trace'    => 1,
    ));

$return = $client->__soapCall("getTimeZoneTime",
   array(new SoapParam('ZULU', 'ns1:timezone')),
   array('soapaction' => 'http://www.Nanonull.com/TimeService/getTimeZoneTime')
);

这篇关于PHP Soap 非 WSDL 调用:如何传递参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Subtract time in PHP(在 PHP 中减去时间)
Limit execution time of an function or command PHP(限制函数或命令 PHP 的执行时间)
How to sum N number of time (HH:MM Format)?(如何求和 N 次(HH:MM 格式)?)
How to get current time in milliseconds in PHP?(如何在 PHP 中以毫秒为单位获取当前时间?)
How to check if time is between two times in PHP(如何检查时间是否在 PHP 中的两次之间)
Convert number of minutes into hours amp; minutes using PHP(将分钟数转换为小时数分钟使用 PHP)