开发者

Webservice error

开发者 https://www.devze.com 2022-12-29 02:06 出处:网络
i am new to webservices, I have created a basic stockmarket webservice, I have successfully created the server script for it and placed it in my server, Now I also creted a clent script and accessed i

i am new to webservices, I have created a basic stockmarket webservice, I have successfully created the server script for it and placed it in my server, Now I also creted a clent script and accessed it hruogh the same server.. Is it valid ? can boh files be accesed from the same server? or do I have to place them in different servers? If yes Then Y? If No then why do i get the blank page? I am using nusoap library for webservice.

When I use my cleint script from my local machine I get these errors

"Deprecated: Assigning the return value of new by reference is deprecated in D:\wamp\www\pranav_test\nusoap\lib\nusoap.php on line 6506

Fatal error: Class 'soapclient' not found in D:\wamp\www\pranav_test\stockclient.php on line 3"

stockserver.php at server

<?php
function getStockQuote($symbol) {
mysql_connect('localhost','root','******');
mysql_select_db('pranav_demo');
$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/lib/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);
?>

stoc开发者_Go百科kclient.php

<?php
require_once('nusoap/lib/nusoap.php');
$c = new soapclient('http://192.168.1.20/pranav_test/stockserver.php');
$stockprice = $c->call('getStockQuote',
array('symbol' => 'ABC'));
echo "The stock price for 'ABC' is $stockprice.";
?>

please help...


Please post a piece of source code.

Yes you can access your webservice from a client which is also located on the same server.

For testing webservices I recommend SoapUI, which is available for all platforms.

I recommend to use the build in soap extension of php then nusoap, it's an rather old library.


I'm really very new to PHP but i found the same error when i was working with nusoap. what i understood that in php 5 you can't assign the return value of new object using referencing ( using the & operator) so simply... Remove it :D... I did that i it worked.


to initiate a soap client with the new php version 5x - there is a conflict with the PHP5 soap library and the NuSoap library.

download the latest nusoap.php library for PHP version 5.3.x (you can get this from sourceforge)

Change the following class call in your client to:

 $c = new soapclient

to

  $c = new nusoap_client

You may also want to add the following to your PHP ini file.

[nusoap_deprecated]
; Turn off deprecated messages on rendered pages
error_reporting = E_ALL & ~E_DEPRECATED
0

精彩评论

暂无评论...
验证码 换一张
取 消