NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Web Services with NuSoap in MS Win Server 2003


Joined: 14 Aug 2007
Posts: 5
Reply with quote
Hello,

I am John from Greece and i have some problems with an application i made using NuSoap.

I made an application using PHP5 for creating a web service for Moodle LMS. I build it in my Win XP Pro SP2 and is working perfectly. When i am testing it with a browser, for example http://localhost/moodle/service.php?wsdl, everything is correct.

I setted up using the same files, the same Moodle version, the same PHP+ MySql etc (i use xampp) to an other computer but then i had this error in my browser: "Fatal error: Cannot redeclare class soapclient in C:\xampp\htdocs\moodle\nutestsoap.php on line 7240".
I have to say that, the Operation System of the other PC is Microsoft Windows Server 2003, Standard Edition, Service Pack 2. I am sure that my code doesn't have any errors because the same error appears when i am using the example "Hello, World Redux" of the "Programming with NuSOAP Using WSDL" tutorial.

I have tryied several things but everything has the same results. Do you know what else sould i try to solve my problem??

That you very much for your attention, looking forward your guidance..

John
View user's profileFind all posts by eaglemanSend private message
Re: Web Services with NuSoap in MS Win Server 2003


Joined: 26 Jul 2007
Posts: 14
Reply with quote
eagleman wrote:
Hello,

I am John from Greece and i have some problems with an application i made using NuSoap.

I made an application using PHP5 for creating a web service for Moodle LMS. I build it in my Win XP Pro SP2 and is working perfectly. When i am testing it with a browser, for example http://localhost/moodle/service.php?wsdl, everything is correct.

I setted up using the same files, the same Moodle version, the same PHP+ MySql etc (i use xampp) to an other computer but then i had this error in my browser: "Fatal error: Cannot redeclare class soapclient in C:\xampp\htdocs\moodle\nutestsoap.php on line 7240".
I have to say that, the Operation System of the other PC is Microsoft Windows Server 2003, Standard Edition, Service Pack 2. I am sure that my code doesn't have any errors because the same error appears when i am using the example "Hello, World Redux" of the "Programming with NuSOAP Using WSDL" tutorial.

I have tryied several things but everything has the same results. Do you know what else sould i try to solve my problem??

That you very much for your attention, looking forward your guidance..

John


soapclient is the same class name as one provided by php 5+, you will need to redeclare the nusoap client's name to something else so you can use it.

i.e.

class nusoap_soapclient extends nusoap_base {

instead of

class soapclient extends nusoap_base {

in nusoap.php
View user's profileFind all posts by addisonpSend private message


Joined: 14 Aug 2007
Posts: 5
Reply with quote
addisonp thank you very mach! It worked fine.
View user's profileFind all posts by eaglemanSend private message
error: no transport found, or selected transport is not yet


Joined: 14 Aug 2007
Posts: 5
Reply with quote
Hello Again...

the problem with the wsdl solved thanks to your help, but now i faced anotehr one! I have this server:

(service.php)
Code:
<?php

   // Pull in the NuSOAP code
   require_once('nusoap.php');
   
   // Create the server instance
   $server = new soap_server();
   
   // Initialize WSDL support
   $server->configureWSDL('ImportCourse', 'urn:ImportCourse');
   
   // Register the method to expose
   $server->register('ImportCourse',                     // method name
       array('xmlstr' => 'xsd:string'),                  // input parameters
       array('return' => 'xsd:string'),                  // output parameters
       'urn:ImportCoursewsdl',                           // namespace
       'urn:ImportCoursewsdl#ImportCourse',              // soapaction
       '',                                               // style
       '',                                               // use
       'Create new Course in Moodle'                     // documentation
   );
   
   // Define the method as a PHP function
   function ImportCourse($xmlstr) {   

         //create new XML to send response
$xml_4_sending = '<response><status>1</status><description>New Course created and all Participants registered successfuly! Notify all students to login to system with username and password their email address and to enroll to this Course.</description></response>';
         
return $xml_4_sending;      
         }

      // 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);

?>


where xmlstr is the xml code in $xml_report variable below

and i am trying to create a client for this server using this code:

(client.php)
Code:


<?php
    // Pull in the NuSOAP code
   require_once('nusoap.php');
   
   $xml_report=<<<XML
<course>    
<activity id='242'>
      <title> Course Fullname </title>   
       <code> Course Shortname</code>
       <abstract> course...</abstract>             
       <startdate>2007/03/15</startdate>      
       <enddate> 2007/12/18</enddate>      
   </activity>
      
   <participants>                     
<participant id='email1@mail.gr'>      
         <firstname> UserFirstname1</firstname>   
              <lastname> UserLastname1</lastname>   
       </participant>
         
        <participant id='email2@mail.gr'>      
              <firstname> UserFirstname2</firstname>   
               <lastname> UserLastname2</lastname>   
         </participant>
         
          <participant id='email3@mail.gr'>      
               <firstname> UserFirstaname3</firstname>   
               <lastname> UserLastname3</lastname>   
          </participant>
         
   </participants>      
</course>
XML;
   
   $wsdl="http://localhost:8081/zenonmoodle/service.php?wsdl";
   $client = new nusoap_soapclient($wsdl, 'wsdl'); 

   // 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
   }

   //SEND via Soap Client Method the XML DATA      
   //echo $client->call('ImportCourse', $xml_report);   
   
   // Call the SOAP method
   $result = $client->call('ImportCourse', $xml_report);   

   // 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>';

?>


although i have changed the name in nusoap.php as you suggested me before, i get the following error to my browser:

no transport found, or selected transport is not yet supported!

why is this happen? any suggestions??

thank you for your patience, looking forword to hearing from you

John
View user's profileFind all posts by eaglemanSend private message
Web Services with NuSoap in MS Win Server 2003
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic