Comet system forum

Discussion forum about Comet system products

Temperature, Humdity,

Pressure Transmitters

and Data Loggers

You are not logged in.

#1 22-06-2012 11:22:15

ngjarman
Member
Registered: 22-06-2012
Posts: 1

SOAP support for thermometer

Has anyone written code to work with the SOAP loggin option?
I have a P8510 but I imagine it's similar with other devices.
I wrote code to inspect the get and put responses, but these seem to be empty.
Now I'm lost and any help would be appreciated.
I tried writing a screen grab but the headers are incomplete so that's a non-starter!
Thanks...

Offline

 

#2 22-06-2012 13:47:24

HonzaD
Administrator
Registered: 11-08-2008
Posts: 294

Re: SOAP support for thermometer

Hi,

Please download this SDK: http://www.cometsystem.cz/userfiles/fil … sdk_v1.zip and read carefully PDF file inside.

But in brief:

Device sends similar XML file as SOAP message:

Code:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<InsertP85xxSample xmlns="http://cometsystem.cz/schemas/soapP85xx_v2.xsd">
<passKey>07940141</passKey>
<device>4352</device>
<temp1>23.1</temp1>
<temp2></temp2>
<temp3></temp3>
<temp4></temp4>
<alarms>lo</alarms>
<tempU>C</tempU>
<timer>10</timer>
</InsertP85xxSample>
</soap:Body>
</soap:Envelope>

And SOAP message you can catch using PHP:

Code:

<?
function InsertP85xxSample($passKey, $device, $temp1, $temp2, $temp3, $temp4,
$alarms, $tempU, $timer) {
$data = "Time: ".StrFTime("%y/%m/%d %H:%M:%S", Time()).", Temp1: ".$temp1."\n";
$file_write = FOpen("soap.log", "a");
FWrite($file_write, $data);
FClose($file_write);
}
$server = new SoapServer(null, array('uri' => "http://test-uri/"));
$server->addFunction(' InsertP85xxSample');
$server->handle();
?>

or

C#:

Code:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.IO;
using System.Text;
using System.Web.Services.Description;

namespace TransmittersWebService
{
    /// <summary>
    /// Example of web service for obtaining values from P85xx transmitters
    /// </summary>

    [SoapDocumentService(RoutingStyle = SoapServiceRoutingStyle.RequestElement)]

    [WebService(Namespace = "http://cometsystem.cz/schemas/soapP85xx_v2.xsd")]

    public class TransmittersSoap : System.Web.Services.WebService
    {

        [WebMethod(Description = "Example of processing sample from P85xx sensor.")]
        public bool InsertP85xxSample(string passKey, string device, string temp1, string temp2, string temp3, string temp4, string alarms, string tempU, string timer)
        {
            string data =   "Time: " +  DateTime.Now.ToString()
                          + ", serial number: " + passKey
                          + ", Temp(1): " + temp1
                          + ", Unit: " + tempU
                          + ", alarms: " + alarms;

            FileStream fs = new FileStream("d:\\temp\\soap.log", FileMode.Append);
            StreamWriter w = new StreamWriter(fs, Encoding.ASCII);
            w.WriteLine(data);
            w.Flush();
            w.Close();
            fs.Close();

            return true;
        }

    }
}

Offline

 

#3 22-09-2012 20:59:12

jjkemp
Member
Registered: 26-09-2008
Posts: 4

Re: SOAP support for thermometer

I just got P8541 with firmware version 4-5-5.02. The SOAP message seems to have changed as it says in manual and can also be seen in
http://www.cometsystem.cz/schemas/soapP8xxx.xsd

Can you provide PHP sample to handle that and is there a SDK file for this new setup?

Offline

 

#4 24-09-2012 12:21:52

JindrichP
Administrator
Registered: 25-06-2007
Posts: 27

Re: SOAP support for thermometer

Hi,

Here is the example of catching SOAP message using PHP for new P8xxx fw 4-5-5.02:

Code:

<?php
function InsertP8xxxSample($name, $sn, $tmr, $kind, $c1, $c2, $c3, $c4, $c5) {

  $link = mysqli_connect("localhost", "root", "comet") or die("connecting to the SQL server failed: " . mysql_error());
  mysqli_select_db($link, "soap_test") or die("selecting database failed");

  $val1 = "NULL";
  $val2 = "NULL";
  $val3 = "NULL";
  $val4 = "NULL";
  $val5 = "NULL";
  if ($c1->e == "1") $val1 = $c1->v;
  if ($c2->e == "1") $val2 = $c2->v;
  if ($c3->e == "1") $val3 = $c3->v;
  if ($c4->e == "1") $val4 = $c4->v;
  if ($c5->e == "1") $val5 = $c5->v;
    
  //create table debug(dt datetime, sn int, val1 float, val2 float, val3 float, val4 float, val5 float)
  $query = "insert into debug (dt, sn, val1, val2, val3, val4, val5) "
         . "values (now(), " . $sn . ", " . $val1 . ", " . $val2 . ", " . $val3 . ", " . $val4 . ", " . $val5 . ")";
  $result = mysqli_query($link, $query);

  if (! $result) 
  {
    error_log("executing query failed", 0);
  }

  mysqli_close($link);

  error_log("processing InsertSample ..FINISHED");
}

$server = new SoapServer(null, array('uri' => "http://test-uri/"));
$server->addFunction('InsertP8xxxSample');
$server->handle();
?>

Offline

 

#5 24-09-2012 16:24:27

jjkemp
Member
Registered: 26-09-2008
Posts: 4

Re: SOAP support for thermometer

Thank you, I got the idea and it works perfect.

However, I spotted what I believe to be "copy&paste - forget to edit" -type of mistake.
Below is the corrected part - should someone need to refer this later.

Code:

  if ($c1->e == "1") $val1 = $c1->v;
  if ($c2->e == "1") $val2 = $c2->v;
  if ($c3->e == "1") $val3 = $c3->v;
  if ($c4->e == "1") $val4 = $c4->v;
  if ($c5->e == "1") $val5 = $c5->v;

Offline

 

#6 25-09-2012 06:53:37

HonzaD
Administrator
Registered: 11-08-2008
Posts: 294

Re: SOAP support for thermometer

jjkemp wrote:

However, I spotted what I believe to be "copy&paste - forget to edit" -type of mistake.

You are right, I fixed previous post.


Jan

Offline

 

Board footer

Powered by PunBB | CZ / SK
© Copyright 2002–2005 Rickard Andersson