作者 主題: 用php建立web service  (閱讀 2704 次)

0 會員 與 1 訪客 正在閱讀本文。

adrianmak

  • 懷疑的國中生
  • **
  • 文章數: 69
    • 檢視個人資料
用php建立web service
« 於: 2004-12-05 07:39 »
apache 2.0.49
php 4.3.9
nusoap 0.63

echoStringClient.php

<?php
require('nusoap.php');
$myString = 'Duetruch Ayala';
$parameters = array($myString);

$s = new soapclient('http://192.168.103.190/soap/echoStringServer.php');

$result = $s->call('echoString',$parameters);

if (!$err = $s->getError()) {
echo 'Result: '.$result;
} else {
echo 'Error: '.$err;
}

echo '<xmp>'.$s->request.'</xmp>';
echo '<xmp>'.$s->response.'</xmp>';

?>

echoStringServer.php
<?php

require('nusoap.php');

$s = new soap_server();

$s->register('echoString');

function echoString($inputString) {
if (is_string($inputString)) {
return $inputString;
} else {
return new soap_fault('Client','','The parameter to this servuce
must be a string.');
}
}

$s->service($HTTP_RAW_POST_DATA);

?>

When I access http://192.168.103.190/soap/echoStringClient.php
it returned
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and
then click the Refresh button, or try again later.

--------------------------------------------------------------------------------

Invalid at the top level of the document. Error processing resource
'http://192.168.103.190/soap/echoStringClient.php'.

What's the problem ? It is just a simple echo string web service