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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.