Home >Backend Development >PHP Tutorial >如何用PHP调用WebService?

如何用PHP调用WebService?

WBOY
WBOYOriginal
2016-06-23 14:39:37727browse

别的系统有个WebService,http://118.145.3.40:9082/mblWebService/services/MaiCarInfoService?wsdl
我想用PHP来调用这个WebService。网上查了一下,这么写的:

$client = new SoapClient("http://118.145.3.40:9082/mblWebService/services/MaiCarInfoService?wsdl",
array('encoding'=>'UTF-8'));
$parm1  = "abcdefg";
$param = array('param0' => $parm1);
$arr = $client->sendMaiCarInfo($param);
var_dump($arr);

本来应该传XML字符串的,我先传个abcdefg测试一下,但是对方说根本没有被调用。
麻烦看一下怎么回事吧。PHP我也不熟啊~~


回复讨论(解决方案)

$parm1  = "abcdefg";$param = array('in0' => $parm1);$arr = $client->sendMaiCarInfo($param);

返回
stdClass Object
(
    [out] => 解析XML出错,不符合XML标准
)

$parm1 = '<root>1234</root>';$param = array('in0' => $parm1);$arr = $client->sendMaiCarInfo($param);

返回
stdClass Object
(
    [out] => success
)

太谢谢啦~~
我的代码没问题吗?一点都不用修改就可以返回成功吗?

对,代码不与要修改
只是要注意参数名
$client->__getFunctions() 返回所有方法名
$client->__getTypes() 返回所有数据结构
你可以看一下

你的问题就在于把参数名写错了

调用WebService的话,php.ini里要改什么吗?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php 调用 C++ dllNext article:求教大大们。