沃梦达 / 编程问答 / php问题 / 正文

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 调用:如何传递参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:PHP Soap 非 WSDL 调用:如何传递参数?

基础教程推荐