Monday, December 21, 2009

Nusoap PHP Request (USING WSDL Document/literal)

// example 2
// include soap file
require_once('nusoap.php');
// set name space
$ns="urn:service";
// set end point
$endpoint = "https://localhost/MethodName";
// create client
$client = new soapclientw($endpoint);

if ( $client->getError() ) {
print "Soap Constructor Error:".
$client->getError()."";
}

$request = 'Yorr XML DATA';
$action = "MethodName";
$msg = $client->serializeEnvelope($request, '', array(), 'document', 'literal');
$result = $client->send($msg, $action, 60, 60);

if ($client->fault) { //soap_fault
print "Soap Fault: (". $client->fault->faultcode .") ".
$client->fault->faultstring. "";
}
elseif ( $client->getError() ) {
print "Soap Error: ". $client->getError() ."";
}
else {
print "Result: ";
print_r($result);
print "";
}

print 'Details:'.
'Request' .
htmlspecialchars( $client->request, ENT_QUOTES) .''.
'Response' .
htmlspecialchars( $client->response, ENT_QUOTES) .''.
'Debug' .
htmlspecialchars( $client->debug_str, ENT_QUOTES) .'';

No comments: