0

i want to display the server's data in multiple rows to the client side. The current implementation shows only one row i.e. value of 'ABC' to client Here is the server side:

<?php
    function getStockQuote($symbol) {

        mysql_connect('server','user','pass');
        mysql_select_db('test');
        $query = "SELECT stock_price FROM stockprices "
               . "WHERE stock_symbol = '$symbol'";
        $result = mysql_query($query);

        $row = mysql_fetch_assoc($result);
        return $row['stock_price'];
    }

    require('nusoap.php');

    $server = new soap_server();

    $server->configureWSDL('stockserver', 'urn:stockquote');

    $server->register("getStockQuote",
                    array('symbol' => 'xsd:string'),
                    array('return' => 'xsd:decimal'),
                    'urn:stockquote',
                    'urn:stockquote#getStockQuote');

    $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
                          ? $HTTP_RAW_POST_DATA : '';
    $server->service($HTTP_RAW_POST_DATA);
?>

And here is the client side:

<?php
    require_once('nusoap.php');

    $c = new soapclient('http://localhost/stockserver.php');

    $stockprice = $c->call('getStockQuote',
              array('symbol' => 'ABC'));

    echo "The stock price for 'ABC' is $stockprice.";

?>
2
  • Post the error please after changes suggested Commented Oct 3, 2013 at 10:45
  • i want to return mutliple rows from the server to the client, how can i do that? pls help Commented Oct 4, 2013 at 6:49

1 Answer 1

1

You must specify an WSDL as endpoint, so change the endpoint with the wsdl, and need to call to your method (call method doesn't exist on your server)

My client code that i test and works:

<?php
require_once('nusoap.php');

$c = new soapclient('http://localhost/stockserver.php?wsdl');

$stockprice = $c->getStockQuote('ABC');
echo "The stock price for 'ABC' is $stockprice.";

?>

And please stop using deprecated mysql_* functions

Sign up to request clarification or add additional context in comments.

14 Comments

See my edited answer, first error says that cannot find a wsdl file,if you don't change the call method then says that theres no method call
I tried with my changes and it works perfectly (y use return "Hello" in server method). Note: I changed again to avoid a Notice error
made the above suggested change.. the error is still there , isnt it related with the nusoap file , i'm actually using php 5.3.5
sorry , was trying some different ways.. and now it shows 'The stock price for 'ABC' is' and perhaps the call to $stockprice = $c->call('getStockQuote',array('symbol' => 'ABC')); is not taking place
Change your client code with mine, as i explained you have to call to the method getStockQuote not to function call that doesn't exist
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.