Home > Backend Development > PHP Tutorial > php怎么调用wcf服务,调用参数是对象参数。

php怎么调用wcf服务,调用参数是对象参数。

WBOY
Release: 2016-06-23 13:25:40
Original
724 people have browsed it

.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 '

'; <br>echo "提供的方法\n"; <br>print_r( $client->__getFunctions ());  <br>echo "相关的数据结构\n"; <br>print_r($client->__getTypes () );  <br>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

求大神帮忙,整了一天了,不知道啥原因。


回复讨论(解决方案)

可怜的孩子 这么长时间都没人回你

我来告诉你吧

$client->GetSuggestList(array(' request'=>$param));

试试这个

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template