Odys Posted March 16, 2007 Share Posted March 16, 2007 I had error with clashes between NuSOAP & PHP_SOAP extension but they have now been resolved ( i think) by changing 'soapclient' to 'sclient' in nusoap.php However now I have new errors, namely: Constructor error: wsdl error: XML error parsing WSDL from http://homepages.cs.ncl.ac.uk/jonathan.olliff-lee/WebServices/MessagingWebService/MessagingServer.php?wsdl on line 2: Invalid document end and Error: XML error parsing SOAP payload on line 2: Invalid document end This both appear on the client page http://homepages.cs.ncl.ac.uk/jonathan.olliff-lee/WebServices/MessagingWebService/MessagingClient.php, the server however throws a different error: Notice: Undefined index: HTTPS in /export/web/homepages.cs/jonathan.olliff-lee/WebServices/MessagingWebService/nusoap.php on line 4006 This can be seen at : http://homepages.cs.ncl.ac.uk/jonathan.olliff-lee/WebServices/MessagingWebService/MessagingServer.php The client source is: Code: <?php // Pull in the NuSOAP code require_once('nusoap.php'); // Create the client instance $client = new sclient('http://homepages.cs.ncl.ac.uk/jonathan.olliff-lee/WebServices/MessagingWebService/MessagingServer.php?wsdl', true); // Check for an error $err = $client->getError(); if ($err) { // Display the error echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; // At this point, you know the call that follows will fail } // Call the SOAP method $result = $client->call('school', array('school' => 'Computer Science')); // Check for a fault if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { // Check for errors $err = $client->getError(); if ($err) { // Display the error echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { // Display the result echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>'; } } // 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>'; // Display the debug messages echo '<h2>Debug</h2>'; echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>'; ?> and the server source is: Code: <?php // Pull in the NuSOAP code require('nusoap.php'); // Create the server instance $server = new soap_server(); // Initialize WSDL support $server->configureWSDL('MessageWebServicewsdl', 'urn:MessageWebServicewsdl'); // Register the method to expose $server->register ( "school", // Method name array('school' => 'xsd:string'), // input parameters array('return' => 'xsd:string'), 'urn:MessageWebServicewsdl', 'urn:MessageWebServicewsdl#school', 'rpc', 'encoded', 'Uses the School to find email addresses in the database' ); // Define The Method As a PHP Function function school($school) { $conn = mysql_connect('host', 'user', 'password') or die ('Error connecting to mysql'); mysql_select_db('database'); $query="SELECT * FROM student WHERE school='$school'"; $result=mysql_query($query); $rows=mysql_num_rows($result); $i=0; while ($i < $rows) { $name = mysql_result($result, $i, 'name'); $email = mysql_result($result, $i, 'email'); $school = mysql_result($result, $i, 'school'); echo $name; echo $school; $message = "Hello $name, This Is A Test Email"; mail($email, 'Test E-Mail', $message); $i++; } mysql_close($conn); return 'Message sent to all students in the school of ' . $school; } // 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); ?> Any help understanding this / finding a solution would be much appreciated! Many thanks, Link to comment https://forums.phpfreaks.com/topic/43049-nusoap-help-xml-error-parsing-wsdl-on-line-2-invalid-document-end/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.