首页 > Web开发 > 详细

kepware http接口 OCaml

时间:2019-03-30 13:37:22      阅读:165      评论:0      收藏:0      [点我收藏+]

 

读取某变量的值

open Cohttp_lwt_unix
open Cohttp
open Lwt

let uri = Uri.of_string "http://127.0.0.1:39321/iotgateway/read?ids=Channel1.Device1.tag1,Channel1.Device1.tag2" in
let headers = Header.init ()
  |> fun h -> Header.add h "Connection" "keep-alive"
  |> fun h -> Header.add h "Cache-Control" "max-age=0"
  |> fun h -> Header.add h "Upgrade-Insecure-Requests" "1"
  |> fun h -> Header.add h "User-Agent" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36"
  |> fun h -> Header.add h "Accept" "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
  |> fun h -> Header.add h "Accept-Encoding" "gzip, deflate, br"
  |> fun h -> Header.add h "Accept-Language" "zh-CN,zh;q=0.9"
  |> fun h -> Header.add h "cache-control" "no-cache"
in

Client.call ~headers `GET uri
>>= fun (res, body_stream) ->
  (* Do stuff with the result *)

 

列出所有变量

open Cohttp_lwt_unix
open Cohttp
open Lwt

let uri = Uri.of_string "http://127.0.0.1:39321/iotgateway/browse" in
let headers = Header.init ()
  |> fun h -> Header.add h "Connection" "keep-alive"
  |> fun h -> Header.add h "Cache-Control" "max-age=0"
  |> fun h -> Header.add h "Upgrade-Insecure-Requests" "1"
  |> fun h -> Header.add h "User-Agent" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36"
  |> fun h -> Header.add h "Accept" "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
  |> fun h -> Header.add h "Accept-Encoding" "gzip, deflate, br"
  |> fun h -> Header.add h "Accept-Language" "zh-CN,zh;q=0.9"
  |> fun h -> Header.add h "cache-control" "no-cache"
in

Client.call ~headers `GET uri
>>= fun (res, body_stream) ->
  (* Do stuff with the result *)

 

kepware http接口 OCaml

原文:https://www.cnblogs.com/dXIOT/p/10626588.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!