Jump to content

consuming my first web service.


tomdelonge

Recommended Posts

I'm trying to learn how to consume a web service using soapclient()

 

I found this WSDL:

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

 

And I tried this code:

$params = array('AAPL');

$client = new SoapClient('http://www.webservicex.net/stockquote.asmx?wsdl');

$result = $client->__soapCall('GetQuote', $params);

print_r($result);

 

But I get this:

 

stdClass Object ( [GetQuoteResult] => exception )

 

I haven't made a single successful call to their api. Also, do you guys know if there's a way to use syntax like this: $client->getQuote();

 

Shouldn't php know from the WSDL what functions are possible?

 

Thanks for your help.

Link to comment
https://forums.phpfreaks.com/topic/205013-consuming-my-first-web-service/
Share on other sites

Without going into code, I will tell you my experience with writing SOAP calls.

 

When I first started writing them, I had issues, because their SOAP calls didn't always conform to the standards.  I found a tool (soapui) to help me build the basic calls, and then reverse-engineered the calls for PHP.  What I would recommend you do is find a good SOAP client, get the hang of it, get used to calls, and then build from there.  You can do calls from SOAPui without much work at all. it will even build the call templates for you.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.