0

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 ?

4

2 回答 2

1

要查看有关客户端的错误信息,您可以添加以下内容:

$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; 
} 

之后,在 server.php 中,可能寄存器需要更多关于返回值的信息。

$server->register('getData', 
  array("response"=>"xsd:string"),
    'http://www.mydowmain.com:8080'
);
于 2015-01-05T09:30:36.370 回答
0

尝试改变这个:

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

进入这个:

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

并在其上定义 $namespace 。这对我有用。

这是我的 NuSOAP 网络服务代码:

require_once("lib/nusoap.php");
$namespace = "http://localhost:8080/Testservice/service.php?wsdl";
$server = new soap_server();
$server->configureWSDL("TestService");
$server->wsdl->schemaTargetNamespace = $namespace;
于 2013-05-17T08:06:50.617 回答