开发者

consuming web service (for the first time) in php

开发者 https://www.devze.com 2023-01-03 22:50 出处:网络
It took me a while to get soap configured in php. Now I\'m just trying to learn about it. I\'m using the web service here to learn:

It took me a while to get soap configured in php. Now I'm just trying to learn about it. I'm using the web service here to learn:

http://www.webservicex.net/WCF/ServiceDetails.aspx?SID=19

It says the WSDL is here:

http://www.webservicex.net/stockquote.asmx?wsdl

and this is my code:

$client = new SoapClient('http://www.webservicex.net/stockquote.asmx?wsdl');
$result = $client->getQuote("AAPL");
echo $result;

I'm getting an error saying "Object of class stdClass could not be converted to string". Now I realize that $result is an object, and I'm wondering how do I access data that the server populated? I tried to understand the WSDL but I'm getting nowhere. Is it supposed to b开发者_如何学编程e something like:

$result->price

? (That doesn't work by the way...)

Ideas?


  1. When curious about datatypes from the soapserver, use the SoapClient->__getTypes() & SoapClient->__getFunctions() methods
  2. If you return is still not clear, var_dump() your return and examine it.
0

精彩评论

暂无评论...
验证码 换一张
取 消