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

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

rob (59)

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

Welches ist Dein Lieblings-Anno?

(171 Stimmen)

1. Ganz klar: Anno 1800!
2. Anno 2205
3. Anno 2070
4. Anno 1404
5. Anno 1701
6. Anno 1503
7. Anno 1602
8. Anno Online

Benutzer-Counter

Besucher gesamt: 1.890.405
Besucher heute: 4.142
Besucher gestern: 12.585
Max. Besucher/Tag: 14.744
Gerade online: 78
Max. online: 314
Seiten gesamt: 42.600.526
Aufrufe diese Seite: 6.656

Tag-Cloud

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