接口-php怎么调用wcf服务,调用参数是对象参数。
程序员文章站
2022-05-25 09:34:44
...
接口php参数
echo "提供的方法\n";
print_r( $client->getFunctions ());
echo "相关的数据结构\n";
print_r($client->getTypes () );
echo '';
?>
浏览器上看到的结果如图:
调用wcf中的这个方法:GetSuggestList
这个方法在接口里面是这样的:
public GetSuggestListResponse GetSuggestList(GetSuggestListRequest request)
所以参数是个对象
我用PHP调用如下:
$client = new SoapClient('http://testu.sh.jinri.com/Flight.User.SOA/SuggestService.svc?wsdl');
$param = array('UserId'=>'1920','PageIndex'=>'1','PageSize'=>'5');
print_r($client->GetSuggestList($param));
但是抛出这样的的错误:
Fatal error: Uncaught SoapFault exception: [a:InternalServiceFault] 未将对象引用设置到对象的实例。 in D:\APMServ5.2.6\www\htdocs\wsdltest\index.php:22 Stack trace: #0 [internal function]: SoapClient->__call('GetSuggestList', Array) #1 D:\APMServ5.2.6\www\htdocs\wsdltest\index.php(22): SoapClient->GetSuggestList(Array) #2 {main} thrown inD:\APMServ5.2.6\www\htdocs\wsdltest\index.php on line 22
.net做的wcf接口,部署IIS*问是可以的如图:
我用php soap调用测试,是否能通,也是可以的:
header('Content-Type: text/plain');
$client = new SoapClient('http://testu.sh.jinri.com/Flight.User.SOA/SuggestService.svc?wsdl');
echo '
echo "提供的方法\n";
print_r( $client->getFunctions ());
echo "相关的数据结构\n";
print_r($client->getTypes () );
echo '';
?>
浏览器上看到的结果如图:
调用wcf中的这个方法:GetSuggestList
这个方法在接口里面是这样的:
public GetSuggestListResponse GetSuggestList(GetSuggestListRequest request)
所以参数是个对象
我用PHP调用如下:
$client = new SoapClient('http://testu.sh.jinri.com/Flight.User.SOA/SuggestService.svc?wsdl');
$param = array('UserId'=>'1920','PageIndex'=>'1','PageSize'=>'5');
print_r($client->GetSuggestList($param));
但是抛出这样的的错误:
Fatal error: Uncaught SoapFault exception: [a:InternalServiceFault] 未将对象引用设置到对象的实例。 in D:\APMServ5.2.6\www\htdocs\wsdltest\index.php:22 Stack trace: #0 [internal function]: SoapClient->__call('GetSuggestList', Array) #1 D:\APMServ5.2.6\www\htdocs\wsdltest\index.php(22): SoapClient->GetSuggestList(Array) #2 {main} thrown inD:\APMServ5.2.6\www\htdocs\wsdltest\index.php on line 22
求大神帮忙,整了一天了,不知道啥原因。