Dav*_*e C 10 php soap web-services
我正在尝试在PHP(5.2.5)中进行非WSDL调用.我确定我错过了一些简单的事情.此调用有一个参数,一个名为"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')
);
Run Code Online (Sandbox Code Playgroud)
谢谢你的任何建议 -
戴夫
Nor*_*ano 11
@Dave C的解决方案对我不起作用.环顾四周,我提出了另一个解决方案:
$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(new SoapVar('ZULU', XSD_DATETIME), 'timezone')),
array('soapaction' => 'http://www.Nanonull.com/TimeService/getTimeZoneTime')
);
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助别人.
Dav*_*e C 10
谢谢.这是现在有效的完整示例:
$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')
);
Run Code Online (Sandbox Code Playgroud)
问题出在参数缺少名称空间信息的地方。我使用了您的示例的第一种情况,因为它与我想出的最接近。
如果更改行:
array(new SoapParam('ZULU', 'timezone')),
Run Code Online (Sandbox Code Playgroud)
至:
array(new SoapParam('ZULU', 'ns1:timezone')),
Run Code Online (Sandbox Code Playgroud)
它应该给您您期望的结果。
| 归档时间: |
|
| 查看次数: |
43265 次 |
| 最近记录: |