php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57824 Unable to call SCA Component consistently using SCA::getService or SoapClient
Submitted: 2007-09-04 17:51 UTC Modified: 2017-01-10 08:09 UTC
From: mattsch at gmail dot com Assigned:
Status: Suspended Package: SCA_SDO (PECL)
PHP Version: 5.2.3 OS: Gentoo Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-04 17:54 UTC] mattsch at gmail dot com
Changed php version.
 [2007-09-04 18:48 UTC] mattsch at gmail dot com
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 line
 [2007-09-05 07:10 UTC] gcc@php.net
Could you provide more details about the call.  The error is mentioning getQuote, but I don't see that call in the example code.

One likely cause of this is SCA's use of the document/literal wrapped WSDL convention.  See http://www-128.ibm.com/developerworks/webservices/library/ws-whichwsdl/ for details on this.  SCA Web services follow this convention of wrapping the call parameters in a data structure named after the operation to be called.  The SCA Soap client knows this and therefore handles the wrapping for the client, so the client only sees the original PHP interface.  If you are using the ext/soap SoapClient, then you will need to modify you calls to explicitly handle the wrapping.

To get a better idea of what the call should look like, you should take a look at the WSDL SCA generates.  

I hope this helps.
 [2007-09-05 10:11 UTC] mattsch at gmail dot com
I neglected to include this in the previous example:

$client->getQuote('FOO');
 [2007-09-05 10:17 UTC] mattsch at gmail dot com
So what do you use to call SCA components?  SCA::getService?   If that's the case, that doesn't work either (Similar to example in docs http://us2.php.net/manual/en/function.SCA-getService.php):

$service = SCA::getService('http://services.work/paymentprocessor/StockQuote.php?wsdl', 'bind.soap', array('location' => 'http://services.work/paymentprocessor'));
$service->getQuote('FOO');

Warning: SCA_Binding_Factory::require(SCA/Bindings/bind.soap/Proxy.php) [function.SCA-Binding-Factory-require]: failed to open stream: No such file or directory in /usr/share/php5/SCA/SCA_BindingFactory.php on line 68

Fatal error: SCA_Binding_Factory::require() [function.require]: Failed opening required 'SCA/Bindings/bind.soap/Proxy.php' (include_path='.:/usr/share/php5:/usr/share/php') in /usr/share/php5/SCA/SCA_BindingFactory.php on line 68
 [2007-09-05 10:18 UTC] mattsch at gmail dot com
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');
 [2007-09-05 10:22 UTC] mattsch at gmail dot com
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:
 [2007-09-05 10:23 UTC] mattsch at gmail dot com
<?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;
  }
}
?>
 [2007-09-05 10:33 UTC] mattsch at gmail dot com
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 6
 [2007-09-05 12:28 UTC] mattsch at gmail dot com
Ok, 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.
 [2007-09-05 13:27 UTC] simonslaws at googlemail dot com
Well that's pretty rubbish. I can only imagine that this is suppressing output from libxml2 from prevent it being echoed  out by PHP and getting mixed up with message responses. 

I think we need to fix this. I'm sure you will not be the only person banging their head on this. Can we trap the stream before the call and then filter if for the word "Fatal" and if found pass the whole lot out as an exception?

Simon
 [2017-01-10 08:09 UTC] kalle@php.net
-Status: Open +Status: Suspended
 [2017-01-10 08:09 UTC] kalle@php.net
Suspending this report as the extension have not had a release for almost 9 years.  Please revive this if the extension once again shows life
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 23:01:32 2024 UTC