Question

I have a php soap webservice which I've created with using NuSOAP. I use the file 'test.php' to test it in the browser as 'http://www.mydowmain.com:8080/webservice/5/test.php'.

My code:

webservice.php

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

 $server = new nusoap_server();

 $server ->configureWSDL('server', 'urn:server'); //this line causes to 'no result'
 $server ->wsdl->schemaTargetNamespace = 'urn:server'; //this line causes to 'no result'
 $server -> register('getData');

 function getData ()
 {
   $items = array(array("item1"),array("item2"));
   return $items;
}

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

test.php

<?php
  require_once('../lib/nusoap.php');
  $client = new nusoap_client("http://www.mydowmain.com:8080/webservice/5/webservice.php?wsdl");

  $result = $client ->call('getData');

  print_r($result);
?>

Problem:

If I remove these lines

$server ->configureWSDL('server', 'urn:server'); 
$server ->wsdl->schemaTargetNamespace = 'urn:server';

it shows me the result fine. Otherwise I get a blank screen, get nothing. But I really need to configure the WSDL.

How can I edit the webservice.php so that the WSDL will be configured and I can get the result array on the test.php ?

Was it helpful?

Solution 2

Try changing this:

$server ->wsdl->schemaTargetNamespace = 'urn:server';

Into this:

 $server ->wsdl->schemaTargetNamespace = $namespace;

and define $namespace on top of it. That did the trick for me.

This is my code of my NuSOAP webservice:

require_once("lib/nusoap.php");
$namespace = "http://localhost:8080/Testservice/service.php?wsdl";
$server = new soap_server();
$server->configureWSDL("TestService");
$server->wsdl->schemaTargetNamespace = $namespace;

OTHER TIPS

To see error information about client you can add this :

$result = $client->call('getData'); 

$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2>' . $err;
// At this point, you know the call that follows will fail
        exit();
}
else 
{ 
echo $result; 
} 

After that, in the server.php, maybe the register needs more information about the return value.

$server->register('getData', 
  array("response"=>"xsd:string"),
    'http://www.mydowmain.com:8080'
);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top