4

PHPでNuSOAPを使用してサンプルWebサービスを実行しようとしていますが、次のサンプルクラスを作成しました。

<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the server instance
$server = new soap_server;
// Register the method to expose
$server->register('hello');
// Define the method as a PHP function
function hello($name) {
    return 'Hello, ' . $name;
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>

そしてクライアントのためのこのクラス:

<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/webServiceResta.php');
// Call the SOAP method
$result = $client->call('hello', array('name' => 'Scott'));
// Display the result
print_r($result);
?>

しかし、スクリプトを実行すると、このエラーが発生するようです。

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost/webServiceResta.php' : Start tag expected, '<' not found in /opt/lampp/htdocs/prueba.php:5 Stack trace: #0 /opt/lampp/htdocs/prueba.php(5): SoapClient->SoapClient('http://localhos...') #1 {main} thrown in /opt/lampp/htdocs/prueba.php on line 5

私はubuntuでXAMPPを使用していますが、すべてのファイルが適切な場所にあります。

4

2 に答える 2

4

NuSoapを使用しているので、呼び出す必要がありますnusoap_client:)

$client = new nusoap_client('http://localhost/webServiceResta.php');
于 2011-09-03T19:35:45.780 に答える
0

Hello,...適切なXMLではなく、適切なSOAP WSDL形式ではないデータ()を送信しています。

参照:http ://www.w3.org/TR/wsdl#_wsdl

于 2010-11-18T02:02:23.297 に答える