WSDL error can someone help

View: New views
11 Messages — Rating Filter:   Alert me  

WSDL error can someone help

by Dooley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I'm getting a strange error when using nusoap with php, both host and client are on a local machine.

Here is the server code.
<?php
function getStockQuote($symbol) {

    mysql_connect('localhost','user','password');
    mysql_select_db('database');
    $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);
?>

When I connect to this via a web browser I can view the wsdl for the service and all seems grand.

This is the client code.

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

$c = new soapclient('http://localhost:80/distribsys/newtest/server.php');

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

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

?>

When i connect I get this error

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost:80/distribsys/newtest/server.php' in /var/www/distribsys/newtest/client.php:4 Stack trace: #0 /var/www/distribsys/newtest/client.php(4): SoapClient->SoapClient('http://localhos...') #1 {main} thrown in /var/www/distribsys/newtest/client.php on line 4

I cannot solve this, I have looked all over the web for solutions and no luck, can anyone guess what could be potentially wrong with this, thanks very much in advance, any help is greatly appreciated.

AW: WSDL error can someone help

by Christian Wenz-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> $c = new
> soapclient('http://localhost:80/distribsys/newtest/server.php');

You forgot the "?wsdl" appendix to the URL.

Best regards
Christian

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: AW: WSDL error can someone help

by Dooley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Christian,

Thanks for the help, one less error. Now there's a new one. Apparently call is a bad function.
Fatal error: Uncaught SoapFault exception: [Client] Function ("call") is not a valid method for this service in /var/www/distribsys/newtest/client.php:6 Stack trace: #0 [internal function]: SoapClient->__call('call', Array) #1 /var/www/distribsys/newtest/client.php(6): SoapClient->call('getStockQuote', Array) #2 {main} thrown in /var/www/distribsys/newtest/client.php on line 6

Notice anything else bad in my code. :P

Thanks again

AW: AW: WSDL error can someone help

by Christian Wenz-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> Fatal error: Uncaught SoapFault exception: [Client] Function ("call")
> is not
> a valid method for this service in
> /var/www/distribsys/newtest/client.php:6
> Stack trace: #0 [internal function]: SoapClient->__call('call', Array)

Since you are using WSDL mode anyway, why don't you try something like this
(after settting $c):

$proxy = $c->getProxy();

$stockprice = $proxy->getStockQuote('ABC');

Best regards
Christian

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: AW: AW: WSDL error can someone help

by Dooley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hmm tried, that similar error.

Fatal error: Uncaught SoapFault exception: [Client] Function ("getProxy") is not a valid method for this service in /var/www/distribsys/newtest/client.php:6 Stack trace: #0 [internal function]: SoapClient->__call('getProxy', Array) #1 /var/www/distribsys/newtest/client.php(6): SoapClient->getProxy() #2 {main} thrown in /var/www/distribsys/newtest/client.php on line 6

This is my clients code.
<?php
require_once('nusoap.php');

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

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

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

?>

AW: AW: AW: WSDL error can someone help

by Christian Wenz-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> $c = new
> soapclient('http://localhost/distribsys/newtest/server.php?wsdl');

Aah, didn't spot that at first. SoapClient is from PHP5's SOAP extension.
Use nusoap_client instead.

If you want to use SoapClient, omit the getProxy() call.

--Christian

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: AW: AW: AW: WSDL error can someone help

by Dooley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Christian,

I think I'm accessing the server now.
Do I need to change any code in my server for implement nusoap? I would prefer to use it over regular SoapClient.

I'm getting the error.
Fatal error: Call to a member function getStockQuote() on a non-object in /var/www/distribsys/newtest/client.php on line 7

Client code here again.
<?php
require_once('../nusoap/lib/nusoap.php');

$c = new nusoap_client('http://localhost:80/distribsys/newtest/server.php?wsdl');

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

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

?>
 
And server is the same.

Thanks again for all the help. It's very much appreciated. I don't know how I would have solved this myself.


Christian Wenz-4 wrote:
> $c = new
> soapclient('http://localhost/distribsys/newtest/server.php?wsdl');

Aah, didn't spot that at first. SoapClient is from PHP5's SOAP extension.
Use nusoap_client instead.

If you want to use SoapClient, omit the getProxy() call.

--Christian

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

AW: AW: AW: AW: WSDL error can someone help

by Christian Wenz-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> $c = new
> nusoap_client('http://localhost:80/distribsys/newtest/server.php?wsdl')

Aah, forgot to tell you to use "true" as the second argument for the
nusoap_client constructor. Then it will work.

If you want to use PHP5-SOAP, refer to http://php.net/soap. However you may
need to generate the WSDL by yourself.

Best regards
Christian

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: AW: AW: AW: AW: WSDL error can someone help

by Dooley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thats fixed it,

Thanks very much Christian, I think i'll stick with nusoap for the the moment, now that Ive got it working. :D

Re: AW: AW: AW: WSDL error can someone help

by usuario76 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you Christian!. You helped me much!

Christian Wenz-4 wrote:
> $c = new
> soapclient('http://localhost/distribsys/newtest/server.php?wsdl');

Aah, didn't spot that at first. SoapClient is from PHP5's SOAP extension.
Use nusoap_client instead.

If you want to use SoapClient, omit the getProxy() call.

--Christian

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: AW: AW: AW: WSDL error can someone help

by mahmudmia :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi. I had the same problems as discussed in this thread. Although my problem did not solve yet. here is my code.....

Server code: stockserver.php
<?php
function getStockQuote($symbol) {

        return "Hello $symbol";

}

require('lib/nusoap.php');

$server = new soap_server();

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

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

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

?>

Client code: stockclient.php

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

$client  = new nusoap_client("http://localhost/soaptest/stockserver.php?wsdl", true);

//$response  = $client->call('getStockQuote',
//              array('symbol' => 'ABC'));

$proxy = $client->getProxy();
$response = $proxy->getStockQuote('ABC');

 if($client->fault)
 {
  echo "FAULT: <p>Code: (".$client->faultcode.")</p>";
  echo "String: ".$client->faultstring;
 }
 else
 {
        echo $response;
  }
 
?>

But nothing is shown on screen and no SOAP error! Can anyone help!

Thanks.


Thank you Christian!. You helped me much!

Christian Wenz-4 wrote:
> $c = new
> soapclient('http://localhost/distribsys/newtest/server.php?wsdl');

Aah, didn't spot that at first. SoapClient is from PHP5's SOAP extension.
Use nusoap_client instead.

If you want to use SoapClient, omit the getProxy() call.

--Christian

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php