Hallo Leute,
ich beschäftige mich gerade mit Soap, speziel mit PEAR:SOAP und jetzt auch mit NuSoap. Mitlerweile arbeite ich nur noch mit NuSoap weil ich damit die besseren erfolge erziehlen konnte. Zu Beginn hatte ich probleme mit komplexen datentypen, aber mit NuSoap konnte ich schnell einen soap server schreiben der auch damit zurecht kommt.
Zur Zeit versuche ich anstatt rpc, document/literal zu verwenden.
Zwar kommt was vom server zurück aber nicht der Rückgabewert.
Habt ihr schon mit NuSoap eure erfahrungen gemacht?
Hier der Server:
Code:
<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the server instance
$server = new soap_server();
// Initialize WSDL support
$NAMESPACE = 'urn:myfirstexample';
$server->configureWSDL('hellowsdl2', $NAMESPACE);
$server->wsdl->schemaTargetNamespace = $NAMESPACE;
// Register the data structures used by the service
$server->wsdl->addComplexType(
'Person',
'complexType',
'struct',
'sequence',
'',
array(
'firstname' => array('name' => 'firstname', 'type' => 'xsd:string', 'minOccurs' => '0', 'maxOccurs' => 'unbounded'),
'age' => array('name' => 'age', 'type' => 'xsd:int', 'minOccurs' => '0', 'maxOccurs' => 'unbounded'),
)
);
// Register the method to expose
$server->register('hello', // method name
array('person' => 'tns:Person'), // input parameters
array('return' => 'xsd:string'), // output parameters
$NAMESPACE, // namespace
'urn:myfirstexample:hello', // soapaction
'document', // style
'literal', // use
'Greet a person entering the sweepstakes' // documentation
);
// Define the method as a PHP function
function hello($person) {
return "nice to meet you" . $person['firstname'];
}
// 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);
?>
und hier der Client
Code:
<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/myfirstexampleDocument.php?wsdl',true);
//create body message
$body = "<hello xmlns=\"urn:myfirstexample:\"><person><firstname>said</firstname><age>25</age></person></hello>";
$message = $client->serializeEnvelope($body);
$client->send($message,"urn:myfirstexample:hello") ;
echo "---------------------------------" ;
echo $client->document;
echo "---------------------------------";
//echo $result;
// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
?>
danke für die Hilfe,
ok bis dann