NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
hello web service problem


Joined: 10 Aug 2004
Posts: 4
Reply with quote
Newbie here - please go easy...

I can get the sample hello web service working for the most part except responding with the input string ($name); that is, I get "Hello !" when it should be "Hello Sam!" where Sam is the input string.

helloServer.php: (remote Linux server)

<?php
require_once('nusoap.php');
$server = new soap_server;
$server->configureWSDL('Test','http://soapinterop.org/');
$server->wsdl->schemaTargetNamespace = 'http://soapinterop.org/xsd/';

$server->register(
'hello',
array('name'=>'xsd:string'),
array('return'=>'xsd:string'),
'http://soapinterop.org/');

function hello($name){
return "Hello $name!";
}

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

helloClient.php:

<?php
require_once('nusoap.php');
$arg = "Sam";
$wsdl = "http://lamp/WC3/helloServer.php?wsdl";
$soap = new soapclient($wsdl,"wsdl");
$proxy = $soap->getProxy();
$result = $proxy->hello($arg);
echo $result;
?>

I also tried with same result:

<?php
require_once('nusoap.php');
$arg = array('name'=>'Sam');
$soap = new soapclient('http://lamp/WC3/helloServer.php');
$result = $soap->call('hello', $arg);
echo $result;
?>

Thanks!
View user's profileFind all posts by dj000Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
make sure nusoap.php is found by the server.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
can find nusoap.php


Joined: 10 Aug 2004
Posts: 4
Reply with quote
Thanks for the quick response.

I'm pretty sure the server can find nusoap.php from couple tests:
- when I remove the require_once('nusoap.php') from server file, I get a "msg parsing error"
- when I rename nusoap.php (path /usr/share/pear/), I get a "required file open error" msg.

I've tried updating nusoap.php from 0.6.3 to 1.7.6 and get the same problem - the server script doesn't receive the $name parameter from client script.

Any other ideas?
View user's profileFind all posts by dj000Send private message


Joined: 10 Aug 2004
Posts: 4
Reply with quote
correction to the previous post -

including nusoap.php 0.6.3 in server file returns the 'Hello' string without the $name string.

including nusoap.php 1.7.6 in server file returns a "xml parsing error"

I should note that both the client and server scripts are on the same server. I can create and successfully consume others' web services, just can't create a simple web service.

I'm sure this is simple but it's driving me nuts!
View user's profileFind all posts by dj000Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
the server part should look like this

Code:
<?php
  require_once('nusoap.php');
  $server = new soap_server;

  $server->configureWSDL('Test','http://soapinterop.org/');

  $server->wsdl->schemaTargetNamespace = 'http://soapinterop.org/xsd/';

  $server->register(
        'hello',
        array('name'=>'xsd:string'),
        array('return'=>'xsd:string'),
        'http://soapinterop.org/');

  function hello($name){
     return "hello" . $name;
  }

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


client part can be built using NuSoap wizard that comes with phped or you can just type the code below:

Code:
<?php
// Nusoap library 'nusoap.php' should be available through include_path directive
require_once('nusoap.php');

// set the URL or path to the WSDL document
$wsdl = "http://yourserver/test.php?wsdl";

// instantiate the SOAP client object
$soap = new soapclient($wsdl,"wsdl");

// get the SOAP proxy object, which allows you to call the methods directly
$proxy = $soap->getProxy();

// set parameter name (string)
$name = "testtt";

// get the result, a native PHP type, such as an array or string
$result = $proxy->hello($name);


?>


I never experienced any problems with that.
Let me know if you still get any problems.
I also can send you URL to the service that you can test by your own.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
hello web service problem
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic