|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-09-04 17:51 UTC] mattsch at gmail dot com
Description:
------------
It's currently impossible to call a function of a SCA component with SoapClient.
Reproduce code:
---------------
StockQuote.php
<?php
include "SCA/SCA.php";
/**
* Scaffold implementation for a remote StockQuote Web service.
*
* @service
* @binding.soap
*
*/
class StockQuote {
/**
* Get a stock quote for a given ticker symbol.
*
* @param string $ticker The ticker symbol.
* @return float The stock quote.
*/
function getQuote($ticker) {
return 80.9;
}
}
?>
test.php
<?
$client = new SoapClient(null, array('uri' => 'http://test/Stockquote.php?wsdl', 'location' => 'http://test/Stockquote.php?wsdl'));
echo $client->getQuote('FOO');
?>
Expected result:
----------------
80.9
Actual result:
--------------
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in /home/www/test/test.php:3 Stack trace: #0 [internal function]: SoapClient->__call('getQuote', Array) #1 /var/www/test/test.php(3): SoapClient->getQuote('FOO') #2 {main} thrown in /var/www/test/test.php on line 3
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 20:00:01 2025 UTC |
Looks like I was specifying Stockquote.php instead of StockQuote.php. There is a different problem. It looks like it's not possible to call the component in non-wsdl mode: $client = new SoapClient(null, array('uri' => 'http://StockQuote', 'location' => 'http://test/StockQuote.php?wsdl')); Result: Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Unable to decode from XML in /home/www/test/test.php:4 Stack trace: #0 [internal function]: SoapClient->__call('getQuote', Array) #1 /home/www/test/test.php(4): SoapClient->getQuote('FOO') #2 {main} thrown in /home/www/test/test.php on lineI neglected to include this in the previous example: $client->getQuote('FOO');Sorry, I meant to type (it still errors out the same anyway): $service = SCA::getService('http://services.work/paymentprocessor/StockQuote.php?wsdl', 'binding.soap', array('location' => 'http://services.work/paymentprocessor')); $service->getQuote('FOO');So it seems to be looking in the wrong spot, so I'll specify this instead even though it goes against the documentation: $service = SCA::getService('http://services.work/paymentprocessor/StockQuote.php?wsdl', 'soap', array('location' => 'http://services.work/paymentprocessor')); $service->getQuote('FOO'); Fatal error: Uncaught SCA_RuntimeException: SDO_Exception in setWSDLTypes : SDO_DAS_XML::create - Unable to parse the supplied xsd file 1 parse error(s) occurred when parsing the file 'http://services.work/paymentprocessor/StockQuote.php?wsdl': 1. xmlSAXUserParseFile returned an error -1 thrown in /usr/share/php5/SCA/Bindings/soap/Proxy.php on line 104 This of course still using this to generate the wsdl:<?php include "SCA/SCA.php"; /** * Credit card processor service component * * @service * @binding.soap * */ class StockQuote { /** * Get a stock quote for a given ticker symbol. * * @param string $ticker The ticker symbol. * @return float The stock quote. */ function getQuote($ticker) { return 80.9; } } ?>Here's my personal favorite that is stumping me. On the first one it works and on the second one it doesn't. The only difference is the filename/classname combination: StockQuote.php: <?php include "SCA/SCA.php"; /** * Scaffold implementation for a remote StockQuote Web service. * * @service * @binding.soap * */ class StockQuote { /** * Get a stock quote for a given ticker symbol. * * @param string $ticker The ticker symbol. * @return float The stock quote. */ function getQuote($ticker) { return 80.9; } } ?> <?php $client = new SoapClient('http://services.work/paymentprocessor/StockQuote.php?wsdl', array('uri' => 'http://StockQuote', 'location' => 'http://services.work/paymentprocessor/StockQuote.php?wsdl')); var_dump($client->getQuote('FOO')); ?> Outputs: object(stdClass)#2 (1) { ["getQuoteReturn"]=> float(80.9) } FooBar.php: <?php include "SCA/SCA.php"; /** * Scaffold implementation for a remote StockQuote Web service. * * @service * @binding.soap * */ class FooBar { /** * Get a stock quote for a given ticker symbol. * * @param string $ticker The ticker symbol. * @return float The stock quote. */ function getQuote($ticker) { return 80.9; } } ?> <?php $client2 = new SoapClient('http://services.work/paymentprocessor/FooBar.php?wsdl', array('uri' => 'http://FooBar', 'location' => 'http://services.work/paymentprocessor/FooBar.php?wsdl')); var_dump($client2->getQuote('FOO')); ?> Outputs: Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in /home/www/services.work/paymentprocessor/test2.php:6 Stack trace: #0 [internal function]: SoapClient->__call('getQuote', Array) #1 /home/www/services.work/paymentprocessor/test2.php(6): SoapClient->getQuote('FOO') #2 {main} thrown in /home/www/services.work/paymentprocessor/test2.php on line 6Ok, after banging my head against the wall for hours, who can I thank for this code? public function setWSDLTypes($wsdl) { SCA::$logger->log('Entering'); SCA::$logger->log("wsdl is $wsdl"); try { $this->xmldas = @SDO_DAS_XML::create($wsdl); } catch ( Exception $e ) { Notice the EVIL @. After removing it, I'm greeted with a more meaningful error: Warning: SDO_DAS_XML::create() [function.SDO-DAS-XML-create]: URL file-access is disabled in the server configuration in /usr/share/php5/SCA/Bindings/soap/Mapper.php on line 66 Warning: SDO_DAS_XML::create(http://services.work/paymentprocessor/StockQuote.php?wsdl) [function.SDO-DAS-XML-create]: failed to open stream: no suitable wrapper could be found in /usr/share/php5/SCA/Bindings/soap/Mapper.php on line 66 Warning: SDO_DAS_XML::create() [function.SDO-DAS-XML-create]: I/O warning : failed to load external entity "http://services.work/paymentprocessor/StockQuote.php?wsdl" in /usr/share/php5/SCA/Bindings/soap/Mapper.php on line 66 Fatal error: Uncaught SCA_RuntimeException: SDO_Exception in setWSDLTypes : SDO_DAS_XML::create - Unable to parse the supplied xsd file 1 parse error(s) occurred when parsing the file 'http://services.work/paymentprocessor/StockQuote.php?wsdl': 1. xmlSAXUserParseFile returned an error -1 thrown in /usr/share/php5/SCA/Bindings/soap/Proxy.php on line 104 After setting allow_url_fopen to "on" in php.ini and restarting Apache, everything magically works with SCA::getService. At any rate, I think this "gotcha" should be added to SDO DAS XML create function documentation so no one runs into this problem again.