Tutorials - Entwicklung - Webservices mit PHP und NuSOAP - WSDL-Support -

Entwicklung: Webservices mit PHP und NuSOAP - WSDL-Support -

rob (45)

rob

12.08.2002 00:42

Vinn

  • 323 Postings, noch 27 bis zum nächsten Level (350)

Postings: 323

Webservices mit PHP und NuSOAP - WSDL-Support -

Dienstag, 06. Januar 2004 12:54

  • 0.0/6 Votes: 0
0.0/6 Votes: 0

WSDL ist die Beschreibung des Webservices und besteht aus den Komponenten: Types, Messages, Operations, Port-Type, Binding, Port und Service.
(kurz gesagt: ein WSDL-File beschreibt was ein Webservice wie liefern kann)

SOAP-Server mit WSDL
der WSDL-Support wird durch die Methode configureWSDL() initialisiert, und erwartet als Parameter den Servicenamen und den Namespace.

$server->configureWSDL('hellowsdl', 'urn:hellowsdl');
oder
$server->configureWSDL('InteropTest','http://soapinterop.org/');

dann wird der WSDL-Schema-Typ für den Namespace gesetzt

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


jetzt noch eine Funktion mit der Methode register() registrieren
$server->register('hello', // method name
array('name' => 'xsd:string'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:hellowsdl', // namespace
'urn:hellowsdl#hello', // soapaction
'rpc', // style
'encoded', // use
'Says hello to the caller' // documentation
);

und das vollständige Script:

<?php
require_once('nusoap.php');
$oServer = new soap_server();

$oServer->configureWSDL('hellowsdl', 'urn:hellowsdl');

$oServer->wsdl->schemaTargetNamespace = 'urn:hellowsdl';

$oServer->register('hallo', // method name
array('name' => 'xsd:string'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:hellowsdl', // namespace
'urn:hellowsdl#hallo', // soapaction
'rpc', // style
'encoded', // use
'Says hello to the caller' // documentation
);
function hallo($sName) {
return 'Hallo, ' . $sName;
}
$oServer->service($HTTP_RAW_POST_DATA);
?>

SOAP-Client mit WSDL-Unterstützung

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

$oClient = new soapclient('phphack/hellowsdl.php?wsdl', true);

$bError = $oClient->getError();
if ($bError) {
echo '<h2>Constructor error</h2><pre>'.$bError.'</pre>';
}

$result = $oClient->call('hello', array('name' => 'Bytefresser'));

if ($oClient->fault) {
print_r($result);
} else {
$bError = $oClient->getError();
if ($bError) {
echo '<h2>Error</h2><pre>'.$bError.'</pre>';
} else {
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
}
?>

weitere Beiträge zum Thema PHP/NuSOAP:

Fehlerbehandlung und Parameterübergabe
Einführung

Zuletzt editiert:Dienstag, 06. Januar 2004 23:28
Bookmark setzen!:Zu Google Bookmark hinzufügen.Zu bloglines hinzufügen.Zu Newsgator hinzufügen.Zu FURL hinzufügen.Zu DIGG hinzufügen.Zu Webnews hinzufügen.Zu Netscape hinzufügen.Zu Yahoo MyWeb hinzufügen.Zu spurl.net hinzufügen.Zu diigo hinzufügen.Zu Newsvine hinzufügen.Zu del.icio.us hinzufügen.Zu SIMPIFY hinzufügen.Zu Mister Wong hinzufügen.Zu Linkarena hinzufügen.Zu isio.de hinzufügen.Zu Oneview hinzufügen.Zu yigg.de hinzufügen.Zu reddit hinzufügen.Zu StumbleUpon hinzufügen.Zu Slashdot hinzufügen.Zu Blinklist hinzufügen.Zu Technorati hinzufügen.Zu Blogmarks hinzufügen.Zu Blinkbits hinzufügen.Zu ma.gnolia hinzufügen.Zu smarking.com hinzufügen.Zu Netvouz hinzufügen.Zu co.mments hinzufügen.Zu Connotea hinzufügen.Zu de.lirio.us hinzufügen.

Specials

Bytefresser Specials: Anno 1404

Umfrage

Hast Du ein Lieblings- Social-Network?

(119 Stimmen)

1. Facebook
2. MySpace
3. StudiVZ
4. MeinVZ
5. Xing
6. Wer-kennt-wen?
7. Stayfriends
8. Anderes
9. Keins

Benutzer-Counter

Besucher gesamt: 816.670
Besucher heute: 151
Besucher gestern: 129
Max. Besucher/Tag: 900
Gerade online: 5
Max. online: 55
Seiten gesamt: 3.098.238
Aufrufe diese Seite: 2.794

Tag-Cloud

  postings     parameter     einführung     level     wsdl-schema-typ     entwicklung     soap-server     dienstag     januar     servicenamen     error     beschreibung     wsdl-support     webservices     nusoap     binding     types     script     wsdl-file     interoptest     tutorials     service     operations     bytefresser     komponenten     port-type     messages     namespace     methode     funktion