cvsoapsvr使iCentroView的SCADA成为了具有Web Service功能的Web站点,基于cvsoap.wsdl文件中描述的访问方式和使用细节,用户可编写客户端调用远程过程访问到SCADA的数据。使用包含以下内容:
u数据获取接口
❖登陆
❖登出
注意:
u必须先登陆之后,才可调用其他接口,否则不予连接。
u登陆后的默认session时间为10分钟,超时后需要重新登录方可正常读取。
u若需要修改session时间,可修改cvsoapsvr.xml中的sessionexpirysecs属性值。参见iCentroView服务端配置。
cvsoapsvr现已加入到iCV默认提供的服务集,采用默认端口50017。
❖如何修改端口:该端口可以修改工程目录下config文件夹中Port.xml关于cvsoapsvr端口标签的内容。
对于5.5.3之前版本的工程,需要在服务管理器中向其添加cvsoapsvr进程,并且在Port.xml中添加以下xml标签<Service name="cvsoapsvr">50017</Service>。如果Port.xml中没有相关描述,默认采用50017端口。
❖如何修改相关配置:cvsoap配置文件为工程目录下的config文件夹中的cvsoapsvr.xml。含如下配置项:
⟡recvtimeout:接收超时
⟡sendtimeout:发送超时
⟡connectiontimeout:套接字连接超时
⟡accepttimeout:接收套接字连接超时
⟡backlog:连接请求队列的最大长度
⟡sessionexpirysecs:会话超时。即login超过该时间设置后,结束会话。需要再次login方可。
❖发布出的wsdl文件可通过URL http://x.x.x.x:port/?wsdl 访问到,IP地址为服务所在SCADA地址,端口见2.1工程目录下config文件夹中Port.xml关于cvsoapsvr端口标签的内容。
❖在安装目录下的executable文件夹内也可找到cvsoap.wsdl。利用该wsdl文件编写SOAP客户端,即可与cvsoapsvr交互。至于如何编写SOAP客户端,已超出本文档的范围(可以使用SOAPUI软件作为客户端进行相关测试)。
u数据获取接口
此接口用于登入cvsoap服务。
⟡客户端请求消息,示例代码如下:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:cvsoap"> <soapenv:Header/> <soapenv:Body> <urn:login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <user xsi:type="xsd:string">admin</user> <passwd xsi:type="xsd:string">admin</passwd> </urn:login> </soapenv:Body> </soapenv:Envelope> |
红色部分传入账号名和密码。
⟡服务端返回消息,如下所示:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="urn:cvsoap"> <SOAP-ENV:Header/> <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <ns:loginResponse> <result>168418524</result> </ns:loginResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> |
蓝色部分为返回值sessionID 。
注意:若其他操作返回的是"Access denied, not authorized to perform operation."时则需要重新执行login操作。
此接口用于登出cvsoap服务。
⟡客户端请求消息,示例代码如下:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:cvsoap"> <soapenv:Header/> <soapenv:Body> <urn:logout soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <sessionid xsi:type="xsd:string">168418524</sessionid> </urn:logout> </soapenv:Body> </soapenv:Envelope> |
红色部分传入sessionID。
⟡服务端返回消息,如下所示:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="urn:cvsoap"> <SOAP-ENV:Header/> <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <ns:logoutResponse> <result>0</result> </ns:logoutResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> |
蓝色部分为返回结果,返回0为成功,返回其他错误码参见错误码对照表 。
此接口传入SCADA名称,返回该SCADA的活动节点IP或机器名。
⟡客户端请求消息,示例代码如下:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:cvsoap"> <soapenv:Header/> <soapenv:Body> <urn:getactiveaddr soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <node xsi:type="xsd:string">scadamain</node> </urn:getactiveaddr> </soapenv:Body> </soapenv:Envelope> |
红色部分传入scadaname。
⟡服务端返回消息,如下所示:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="urn:cvsoap"> <SOAP-ENV:Header/> <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <ns:getactiveaddrResponse> <result>192.168.128.121</result> </ns:getactiveaddrResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> |
蓝色部分为返回的活动节点IP。
注意:若该操作返回的值是"Get tag list failed."时请检查输入的SCADA节点名是否正确。
此接口传入SCADA名称,返回该SCADA下所有点的名称。
⟡客户端请求消息,示例代码如下:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:cvsoap"> <soapenv:Header/> <soapenv:Body> <urn:gettaglist soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <node xsi:type="xsd:string">zyqscada</node> </urn:gettaglist> </soapenv:Body> </soapenv:Envelope> |
红色部分传入scadaname。
⟡服务端返回消息,如下所示:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="urn:cvsoap"> <SOAP-ENV:Header/> <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <ns:gettaglistResponse> <result> <val>ALMAREA.ALL</val> <val>ALMAREA.a</val> <val>ALMAREA.b</val> <val>ALMAREA.c</val> <val>ALMAREA.d</val> <val>ALMAREA.la</val> <val>ALMAREA.mdi</val> <val>ALMAREA.subsystem</val> <val>FreeDisk</val> <val>SYSTEM.ALMFILTER</val> <val>SYSTEM.LICENSE</val> <val>SYSTEM.RMSTATUS</val> <val>rdatest_ai</val> <val>trig</val> <val>trig_chang_1_0</val> <val>trig_chang_1_1</val> <val>trig_sqlcount</val> <val>trig_timestamp_a</val> <val>trig_timestamp_f</val> </result> </ns:gettaglistResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> |
蓝色部分为返回的tag点。
读值时传入参数格式为每个查询项遵从“SCADA名.点名.域名”的三段式,并支持批量查询,各个查询项之间用分号隔开即可。返回的每个查询项的查询结果的格式为“查询项名称;查询结果”。
⟡客户端请求消息,示例代码如下:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:cvsoap"> <soapenv:Header/> <soapenv:Body> <urn:read soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <ntf xsi:type="xsd:string">zyqscada.trig.F_CV;zyqscada.trig_timestamp_f.F_CV</ntf> </urn:read> </soapenv:Body> </soapenv:Envelope> |
红色部分为需要读取的tag点。可以同时读取多个,以分号分隔。
⟡服务端返回消息,如下所示:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="urn:cvsoap"> <SOAP-ENV:Header/> <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <ns:readResponse> <result> <val>zyqscada.trig.F_CV;0</val> <val>zyqscada.trig_timestamp_f.F_CV;2014-06-02 09:46:52.491</val> </result> </ns:readResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> |
蓝色部分为返回的tag点值及其值。
写值时传入参数为点名、要下发的值、用户名及描述信息。返回控制是否成功,成功为0,失败为非0的错误码,错误码信息对照表详见错误码对照表。
⟡客户端请求消息,示例代码如下:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:cvsoap"> <soapenv:Header/> <soapenv:Body> <urn:write soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <ntf xsi:type="xsd:string">zyqscada.trig</ntf> <value xsi:type="xsd:string">1</value> <desc xsi:type="xsd:string">描述</desc> </urn:write> </soapenv:Body> </soapenv:Envelope> |
红色部分为需要传入的值,第一行为需要write的tag点,第二行为欲写的值,第三行为描述。一次只能写一个点。
⟡服务端返回消息,如下所示:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="urn:cvsoap"> <SOAP-ENV:Header/> <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <ns:writeResponse> <result>0</result> </ns:writeResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> |
蓝色部分为返回值,若写成功,则返回0,否则返回错误码,参见错误码对照表 。