1 Reply Latest reply on Jul 13, 2009 12:25 PM by webcontrol

    Change Monitorstatus using SOAP and PHP

    webcontrol

      I need to provide our customers a way to disable/suspend/enable monitors/devices which we watch for them. I am a big fan of crossplattform scripting so i only use PHP and Perl on Windows and Linux. ASP.NET is no option.

      So far i have written the necessary scripts to read all relevant informations (groups, monitors, ids, names, etc.) with PHP using nuSoap. E.g. to get all Groups i use:

      <?php
      require_once('../lib/nusoap.php');
      echo '<pre>';

      $wsdl = "https://my_ipmonitor_domainname/soap/status.asmx";
      $client = new soapclient($wsdl, false);
      $client->setCredentials('my_account','my_password','basic');

      $mysoapmsg = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body><GetGroups xmlns="http://schemas.ipmonitor.com/ipm70/" /></soap:Body></soap:Envelope>';

      $soapaction = "http://schemas.ipmonitor.com/ipm70/GetGroups";

      $result = $client->send($mysoapmsg, $soapaction);

      print_r($result);
      #actualy here are done some other task to store data into a hash (associative array)

      echo '</pre>';
      ?>

      The example above is now modified for other soap actions like GetMonitors or Monitorview (then using config.asmx). As i wrote reading the informations is not the problem.

      The tricky part seems to be to change values of groups and monitors. http://support.ipmonitor.com/devdocs/5a7bc4f48b324a96b214b46228fcb4b5.aspx explains the invoke details as follows:

      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
      <MonitorEdit xmlns="http://schemas.ipmonitor.com/ipm70/">
      <Settings>xml</Settings>
      </MonitorEdit>
      </soap:Body>
      </soap:Envelope>

      However the <Settings>xml</Settings> is not described in any way. Whatever i do the soap function MonitorEdit gives back "false". My current code is:

      <?php
      require_once('../lib/nusoap.php');
      echo '<pre>';

      $wsdl = "https://my_ipmonitor_domainname/soap/config.asmx";

      $client = new soapclient($wsdl, false);
      $client->setCredentials('my_account','my_password','basic');

      $mysoapmsg = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
      <MonitorEdit xmlns="http://schemas.ipmonitor.com/ipm70/">
      <Settings>
      <monitor>
      <id>2784343672959</id>
      <enabled>false</enabled>
      </monitor>
      </Settings>
      </MonitorEdit>
      </soap:Body></soap:Envelope>';

      $soapaction = "http://schemas.ipmonitor.com/ipm70/MonitorEdit";

      $client->setGlobalDebugLevel(9);

      $result = $client->send($mysoapmsg, $soapaction);

      print_r($result);

      echo '</pre>';
      ?>

      The response is:

      Result

      Array
      (
          [MonitorEditResult] => false
      )

       

      The ID used is correct (verified by checking the xml popup of the monitor in question.
      The SOAP call is working otherwise i would not get the result from MonitorEditResult.
      Enabled should be set to false if the customer wants to disable the monitor, otherwise to true (suspend is not available as i have read in an other post).
      The account used has all rights in ipmonitor (it is the admin).

      Therefore i assume it is the code between the <settings> tag. What format does ipmonitor expect 'xml' to be?

      Regards

       

      Michael